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


Python pip.main方法代碼示例

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


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

示例1: handle_dependencies

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def handle_dependencies(plugin):
    path = user_plugin_path.replace('plugins', 'repositories/default/plugins')
    plugin_json = '{}/{}/plugin.json'.format(path, plugin.path)
    try:
        with open(plugin_json, 'r') as jsonfile:
            raw_data = json.load(jsonfile)
            dependencies = raw_data["plugin"]["dependencies"]
            if "pip" in dependencies:
                for package in dependencies["pip"]:
                    print("Installing {} dependency: {}".format(plugin.name, package))
                    try:
                        pip.main(['install', '-q', package])
                    except IOError:
                        print("Unable to install {}. Permissions?".format(package))
                        traceback.print_exc()
    except IOError:
        log_error("Unable to install dependencies for {}. Permissions?".format(plugin.name))
        traceback.print_exc() 
開發者ID:nccgroup,項目名稱:binja_sensei,代碼行數:20,代碼來源:__init__.py

示例2: execute_target

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def execute_target(cls, *unused):
            # check which requirements should be installed
            requirements_file = _CommonTargets.get_requirements_file()

            # install the requirements
            _CommonTargets.activate_virtual_environment()
            # fix for pip versions below 10.0
            try:
                from pip._internal import main as pipmain
            except ImportError:
                from pip import main as pipmain
            code = pipmain(["install", "-r", requirements_file])

            # check for possible errors
            if code != 0:
                _CommonTargets.exit("Failed while installing the requirements! Please check the errors above.", code)

            # reload the installed packages
            importlib.reload(site) 
開發者ID:iguana-project,項目名稱:iguana,代碼行數:21,代碼來源:make.py

示例3: main

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def main():
    """
    Main function exposed as script command.
    """
    DATA_PATH = pkg_resources.resource_filename('marcotti', 'data/')
    setup_dict = setup_user_input()
    print("#### Installing database driver ####")
    if setup_dict['dialect'] == 'sqlite':
        print('SQLite database is used -- no external driver needed')
    else:
        pip.main(['install', db_modules.get(setup_dict['dialect'])])
    print("#### Creating settings and data loader modules ####")
    env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath=DATA_PATH),
                             trim_blocks=True, lstrip_blocks=True)
    template_files = ['local.skel', 'logging.skel', 'loader.skel']
    output_files = ['{config_file}.py'.format(**setup_dict),
                    'logging.json',
                    '{loader_file}.py'.format(**setup_dict)]
    for template_file, output_file in zip(template_files, output_files):
        template = env.get_template(os.path.join('templates', template_file))
        with open(output_file, 'w') as g:
            result = template.render(setup_dict)
            g.write(result)
            print("Configured {}".format(output_file))
    print("#### Setup complete ####") 
開發者ID:soccermetrics,項目名稱:marcotti,代碼行數:27,代碼來源:dbsetup.py

示例4: _handle_install

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def _handle_install(args, dependencies):
    if args.install and dependencies:
        if pip is None:
            raise ImportError("Bootstrapping Pulsar dependencies requires pip library.")

        pip.main(["install"] + dependencies)


# def _install_pulsar_in_virtualenv(venv):
#     if virtualenv is None:
#         raise ImportError("Bootstrapping Pulsar into a virtual environment, requires virtualenv.")
#     if IS_WINDOWS:
#         bin_dir = "Scripts"
#     else:
#         bin_dir = "bin"
#     virtualenv.create_environment(venv)
#     # TODO: Remove --pre on release.
#     subprocess.call([os.path.join(venv, bin_dir, 'pip'), 'install', "--pre", "pulsar-app"]) 
開發者ID:galaxyproject,項目名稱:pulsar,代碼行數:20,代碼來源:config.py

示例5: main

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def main():
    tmpdir = None
    try:
        # Create a temporary working directory
        tmpdir = tempfile.mkdtemp()

        # Unpack the zipfile into the temporary directory
        pip_zip = os.path.join(tmpdir, "pip.zip")
        with open(pip_zip, "wb") as fp:
            fp.write(b85decode(DATA.replace(b"\n", b"")))

        # Add the zipfile to sys.path so that we can import it
        sys.path.insert(0, pip_zip)

        # Run the bootstrap
        bootstrap(tmpdir=tmpdir)
    finally:
        # Clean up our temporary working directory
        if tmpdir:
            shutil.rmtree(tmpdir, ignore_errors=True) 
開發者ID:pypa,項目名稱:get-pip,代碼行數:22,代碼來源:pre-10.py

示例6: package_dependencies

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def package_dependencies(self, build_dir):
        thirdparty_dir = os.path.join(build_dir, 'third-party')

        requirements = self.distribution.install_requires
        for requirement in requirements:
            pip.main(['wheel',
                      '--wheel-dir={0}'.format(thirdparty_dir),
                      '--no-cache',
                      requirement])

        pip.main(['install',
                  '-d',
                  thirdparty_dir,
                  '--no-cache',
                  '--no-use-wheel',
                  'virtualenv=={0}'.format(self.virtualenv_version)]) 
開發者ID:prestodb,項目名稱:presto-admin,代碼行數:18,代碼來源:bdist_prestoadmin.py

示例7: update

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def update(supervisor):

  os.chdir(BASE_DIR)
  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "panel.settings")

  tracked = repo.active_branch.tracking_branch()
  if repo.git.rev_parse("@") == repo.git.rev_parse(tracked):
    click.secho('Hawthorne is already up-to-date', bold=True, fg='green')
    return

  repo.git.pull()
  pip.main(['install', '-U', '-r', BASE_DIR + '/requirements.txt'])
  call_command('migrate', interactive=False)
  call_command('collectstatic', interactive=False)

  timezones = run(['mysql_tzinfo_to_sql', '/usr/share/zoneinfo'],
                  stdout=PIPE, stderr=PIPE).stdout
  with connection.cursor() as cursor:
    cursor.execute('USE mysql')
    cursor.execute(timezones)

  if supervisor and which('supervisorctl'):
    run(['supervisorctl', 'reread'], stdout=PIPE, stderr=PIPE)
    run(['supervisorctl', 'update'], stdout=PIPE, stderr=PIPE)
    run(['supervisorctl', 'restart', 'hawthorne:*'], stdout=PIPE, stderr=PIPE) 
開發者ID:indietyp,項目名稱:hawthorne,代碼行數:27,代碼來源:helper.py

示例8: do

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def do(action, dependency):
    return pip.main([action, dependency]) 
開發者ID:anatolikalysch,項目名稱:VMAttack,代碼行數:4,代碼來源:setup.py

示例9: printInfo

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def printInfo():
    print("Usage:")
    print("  main [option...] file/folder")
    print("\nPacking Options:")
    print(" -o <output>           output file name (Optional)")
    print(" -little (or -l)       output will be in little endian if this is used")
    print(" -compress <level>     Yaz0 (SZS) compress the output with the specified level(0-9) (1 is the default)")
    print("                       0: No compression (Fastest)")
    print("                       9: Best compression (Slowest)")
    print("\nExiting in 5 seconds...")
    time.sleep(5)
    sys.exit(1) 
開發者ID:aboood40091,項目名稱:SARC-Tool,代碼行數:14,代碼來源:main.py

示例10: dependencies

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def dependencies(option):
    """install script dependencies with pip"""

    try:
        with open("requirements.txt", "r") as requirements:
            dependencies = requirements.read().splitlines()
    except IOError:
        print "requirements.txt not found, please redownload or do pull request again"
        exit(1)

    for lib in dependencies:
        pip.main([option, lib]) 
開發者ID:the-robot,項目名稱:sqliv,代碼行數:14,代碼來源:setup.py

示例11: install_packages

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def install_packages(dest, packages):
    for p in packages:
        pip.main(['install', '-t', dest, p]) 
開發者ID:ellimilial,項目名稱:sqs-s3-logger,代碼行數:5,代碼來源:lambda_function_builder.py

示例12: pip

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def pip(packages):
    click.echo("Running: pip3 install %s" % packages)
    import pip
    pip.main(['install'] + packages.split(" "))
    return True 
開發者ID:laurivosandi,項目名稱:certidude,代碼行數:7,代碼來源:common.py

示例13: vendor

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def vendor():
    pip.main(['install', '-t', here, '-r', 'vendor.txt'])
    for dirname in glob.glob('*.egg-info'):
        shutil.rmtree(dirname) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:re-vendor.py

示例14: crawl

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def crawl(self, container_id=None, **kwargs):

        try:
            import redis
        except ImportError:
            import pip
            pip.main(['install', 'redis'])
            import redis

        # only crawl redis container. Otherwise, quit.
        c = dockercontainer.DockerContainer(container_id)
        port = self.get_port(c)

        if not port:
            return

        state = c.inspect['State']
        pid = str(state['Pid'])
        ips = run_as_another_namespace(
            pid, ['net'], utils.misc.get_host_ip4_addresses)

        for each_ip in ips:
            if each_ip != "127.0.0.1":
                ip = each_ip
                break

        client = redis.Redis(host=ip, port=port)

        try:
            metrics = client.info()
            feature_attributes = feature.create_feature(metrics)
            return [(self.feature_key, feature_attributes, self.feature_type)]
        except:
            logger.info("redis does not listen on port:%d", port)
            raise ConnectionError("no listen at %d", port) 
開發者ID:cloudviz,項目名稱:agentless-system-crawler,代碼行數:37,代碼來源:redis_container_crawler.py

示例15: crawl

# 需要導入模塊: import pip [as 別名]
# 或者: from pip import main [as 別名]
def crawl(self, root_dir='/', **kwargs):
        import pip
        pip.main(['install', 'redis'])
        import redis

        try:
            client = redis.Redis(host='localhost', port=self.default_port)
            metrics = client.info()
        except ConnectionError:
            logger.info("redis does not listen on port:%d", self.default_port)
            raise ConnectionError("no listen at %d", self.default_port)

        feature_attributes = feature.create_feature(metrics)

        return [(self.feature_key, feature_attributes, self.feature_type)] 
開發者ID:cloudviz,項目名稱:agentless-system-crawler,代碼行數:17,代碼來源:redis_host_crawler.py


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