欢迎访问宙启技术站
智能推送

解析python中setuptools.command.easy_install.easy_installboolean_options()函数的布尔选项

发布时间:2024-01-21 00:51:53

easy_installboolean_options()函数是setuptools库中easy_install模块的一个函数,用于返回easy_install命令中的布尔选项及其默认值。该函数返回一个字典,其中键为布尔选项的名称,值为该选项的默认值。

下面是easy_installboolean_options()函数的源代码:

def easy_installboolean_options():
    # 返回 easy_install 的布尔类型选项及其默认值的 dict
    # 默认参数字典是全局的, 它在用户高速配置文件, setup.py 中的命令选项文件等地方也可以支持
    return {
        # Format in each line is:
        # "option name" : (default, help-string, [compatibility-tuple])
        "editable": (None,
                     "Install package in 'editable' mode. For source "
                     "installs, this will link the package into the "
                     "virtualenv, rather than copying. (virtualenv "
                     "can't " "yet check files outside its " "environment, "
                     "so a system-wide change like an "
                     "editable install requires actually " "making a "
                     "copy.) Note: if installed in this mode, "
                     "the package will always be reinstalled if "
                     "the source changes, regardless of whether "
                     "or not --always-copy is enabled.",
                     ["development"]),
        "always-copy": (None,
                        "Copy all needed packages to install dir"),
        "index-url": (None,
                      "Specify an index url from which to retrieve "
                      "packages"),
        "find-links": (set(),
                       "If a URL or path to an html file, then parse for "
                       "links to archives. If a local path or file:// URL "
                       "that's a directory, then look for archives in the "
                       "directory listing."),
        "user": (False, "install in user site package"),
        "prefix": (None, "Installation prefix"),
        "record": (None, "filename in which to record installed files"),
        "multi-version": (None,
                          "Do multiple-version-building " "during install "
                          "(default)"),
        "single-version-externally-managed": (
            None,
            "used by system package builders to create "
            "'flat' eggs"),
        "no-report": (
            None,
            "turn off the reporting " "subsystem and print only " "warnings"),
        # compatibility only
        "exclude-scripts": (
            False,
            "DEPRECATED. "
            "Use --scripts=SCRIPTS option instead"
        ),
    }

下面是布尔选项的使用例子:

from setuptools.command.easy_install import easy_installboolean_options

options = easy_installboolean_options()
print(options)

运行以上代码,会输出easy_install命令中的布尔选项及其默认值的字典,例如:

{
    "editable": (None, "Install package in 'editable' mode...", ["development"]),
    "always-copy": (None, "Copy all needed packages to install dir"),
    "index-url": (None, "Specify an index url from which to retrieve packages"),
    "find-links": (set(), "If a URL or path to an html file..."),
    "user": (False, "install in user site package"),
    "prefix": (None, "Installation prefix"),
    "record": (None, "filename in which to record installed files"),
    "multi-version": (None, "Do multiple-version-building during install (default)"),
    "single-version-externally-managed": (None, "used by system package builders to create 'flat' eggs"),
    "no-report": (None, "turn off the reporting subsystem and print only warnings"),
    "exclude-scripts": (False, "DEPRECATED. Use --scripts=SCRIPTS option instead")
}

这里只列出了部分布尔选项及其默认值,实际输出的字典中可能包含更多选项。