當前位置: 首頁>>代碼示例>>Python>>正文


Python install.InstallCommand方法代碼示例

本文整理匯總了Python中pip.commands.install.InstallCommand方法的典型用法代碼示例。如果您正苦於以下問題:Python install.InstallCommand方法的具體用法?Python install.InstallCommand怎麽用?Python install.InstallCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip.commands.install的用法示例。


在下文中一共展示了install.InstallCommand方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: patch_setuptools

# 需要導入模塊: from pip.commands import install [as 別名]
# 或者: from pip.commands.install import InstallCommand [as 別名]
def patch_setuptools(fetch_directives=('index_url', 'find_links')):

    orig = easy_install.finalize_options

    def patched_finalize_options(self):
        cmd = PipInstallCommand()
        config = cmd.parser.parse_args([])[0]
        for option in fetch_directives:
            try:
                value = getattr(config, option)
            except AttributeError:
                continue
            setattr(self, option, value)
        orig(self)

    easy_install.finalize_options = patched_finalize_options 
開發者ID:ncbi,項目名稱:packit,代碼行數:18,代碼來源:core.py

示例2: install_missing_requirements

# 需要導入模塊: from pip.commands import install [as 別名]
# 或者: from pip.commands.install import InstallCommand [as 別名]
def install_missing_requirements(module):
    """
    Some of the modules require external packages to be installed. This gets
    the list from the `REQUIREMENTS` module attribute and attempts to
    install the requirements using pip.
    :param module: GPIO module
    :type module: ModuleType
    :return: None
    :rtype: NoneType
    """
    reqs = getattr(module, "REQUIREMENTS", [])
    if not reqs:
        _LOG.info("Module %r has no extra requirements to install." % module)
        return
    import pkg_resources
    pkgs_installed = pkg_resources.WorkingSet()
    pkgs_required = []
    for req in reqs:
        if pkgs_installed.find(pkg_resources.Requirement.parse(req)) is None:
            pkgs_required.append(req)
    if pkgs_required:
        from pip.commands.install import InstallCommand
        from pip.status_codes import SUCCESS
        cmd = InstallCommand()
        result = cmd.main(pkgs_required)
        if result != SUCCESS:
            raise CannotInstallModuleRequirements(
                "Unable to install packages for module %r (%s)..." % (
                    module, pkgs_required)) 
開發者ID:flyte,項目名稱:pi-mqtt-gpio,代碼行數:31,代碼來源:server.py

示例3: install

# 需要導入模塊: from pip.commands import install [as 別名]
# 或者: from pip.commands.install import InstallCommand [as 別名]
def install(params):
    """
    Install third-party Mod
    """
    from pip import main as pip_main
    from pip.commands.install import InstallCommand

    params = [param for param in params]

    options, mod_list = InstallCommand().parse_args(params)

    params = ["install"] + params

    for mod_name in mod_list:
        mod_name_index = params.index(mod_name)
        if mod_name in system_mod:
            print('System Mod can not be installed or uninstalled')
            return
        if "rqalpha_mod_" in mod_name:
            lib_name = mod_name
            mod_name = lib_name.replace("rqalpha_mod_", "")
        else:
            lib_name = "rqalpha_mod_" + mod_name
        params[mod_name_index] = lib_name

    # Install Mod
    pip_main(params)

    # Export config
    config_path = get_default_config_path()
    config = load_config(config_path, loader=yaml.RoundTripLoader)

    for mod_name in mod_list:
        if "rqalpha_mod_" in mod_name:
            lib_name = mod_name
            mod_name = lib_name.replace("rqalpha_mod_", "")
        else:
            lib_name = "rqalpha_mod_" + mod_name

        mod = import_module(lib_name)

        mod_config = yaml.load(mod.__mod_config__, yaml.RoundTripLoader)

        config['mod'][mod_name] = mod_config
        config['mod'][mod_name]['lib'] = lib_name
        config['mod'][mod_name]['enabled'] = False
        config['mod'][mod_name]['priority'] = 1000

    dump_config(config_path, config) 
開發者ID:zhengwsh,項目名稱:InplusTrader_Linux,代碼行數:51,代碼來源:__main__.py

示例4: bootstrap

# 需要導入模塊: from pip.commands import install [as 別名]
# 或者: from pip.commands.install import InstallCommand [as 別名]
def bootstrap(tmpdir=None):
    # Import pip so we can use it to install pip and maybe setuptools too
    import pip
    from pip.commands.install import InstallCommand

    # Wrapper to provide default certificate with the lowest priority
    class CertInstallCommand(InstallCommand):
        def parse_args(self, args):
            # If cert isn't specified in config or environment, we provide our
            # own certificate through defaults.
            # This allows user to specify custom cert anywhere one likes:
            # config, environment variable or argv.
            if not self.parser.get_default_values().cert:
                self.parser.defaults["cert"] = cert_path  # calculated below
            return super(CertInstallCommand, self).parse_args(args)

    pip.commands_dict["install"] = CertInstallCommand

    # We always want to install pip
    packages = ["pip"]

    # Check if the user has requested us not to install setuptools
    if "--no-setuptools" in sys.argv or os.environ.get("PIP_NO_SETUPTOOLS"):
        args = [x for x in sys.argv[1:] if x != "--no-setuptools"]
    else:
        args = sys.argv[1:]

        # We want to see if setuptools is available before attempting to
        # install it
        try:
            import setuptools  # noqa
        except ImportError:
            packages += ["setuptools"]

    delete_tmpdir = False
    try:
        # Create a temporary directory to act as a working directory if we were
        # not given one.
        if tmpdir is None:
            tmpdir = tempfile.mkdtemp()
            delete_tmpdir = True

        # We need to extract the SSL certificates from requests so that they
        # can be passed to --cert
        cert_path = os.path.join(tmpdir, "cacert.pem")
        with open(cert_path, "wb") as cert:
            cert.write(pkgutil.get_data("pip._vendor.requests", "cacert.pem"))

        # Execute the included pip and use it to install the latest pip and
        # setuptools from PyPI
        sys.exit(pip.main(["install", "--upgrade"] + packages + args))
    finally:
        # Remove our temporary directory
        if delete_tmpdir and tmpdir:
            shutil.rmtree(tmpdir, ignore_errors=True) 
開發者ID:PacktPublishing,項目名稱:Arduino-Building-exciting-LED-based-projects-and-espionage-devices,代碼行數:57,代碼來源:get-pip.py


注:本文中的pip.commands.install.InstallCommand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。