当前位置: 首页>>代码示例>>Python>>正文


Python pip.get_installed_distributions方法代码示例

本文整理汇总了Python中pip.get_installed_distributions方法的典型用法代码示例。如果您正苦于以下问题:Python pip.get_installed_distributions方法的具体用法?Python pip.get_installed_distributions怎么用?Python pip.get_installed_distributions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip的用法示例。


在下文中一共展示了pip.get_installed_distributions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: collect_loaded_packages

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def collect_loaded_packages() -> List[Tuple[str, str]]:
    """
    Return the currently loaded package names and their versions.
    """
    dists = get_installed_distributions()
    get_dist_files = DistFilesFinder()
    file_table = {}
    for dist in dists:
        for file in get_dist_files(dist):
            file_table[file] = dist
    used_dists = set()
    # we greedily load all values to a list to avoid weird
    # "dictionary changed size during iteration" errors
    for module in list(sys.modules.values()):
        try:
            dist = file_table[module.__file__]
        except (AttributeError, KeyError):
            continue
        used_dists.add(dist)
    return sorted((dist.project_name, dist.version) for dist in used_dists) 
开发者ID:src-d,项目名称:modelforge,代码行数:22,代码来源:environment.py

示例2: collect_environment

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def collect_environment(self, overwrite_variables=None):
        import socket
        import os
        import pip
        import platform

        env = {}

        if not overwrite_variables:
            overwrite_variables = {}

        import aetros
        env['aetros_version'] = aetros.__version__
        env['python_version'] = platform.python_version()
        env['python_executable'] = sys.executable

        env['hostname'] = socket.gethostname()
        env['variables'] = dict(os.environ)
        env['variables'].update(overwrite_variables)

        if 'AETROS_SSH_KEY' in env['variables']: del env['variables']['AETROS_SSH_KEY']
        if 'AETROS_SSH_KEY_BASE64' in env['variables']: del env['variables']['AETROS_SSH_KEY_BASE64']

        env['pip_packages'] = sorted([[i.key, i.version] for i in pip.get_installed_distributions()])
        self.set_system_info('environment', env) 
开发者ID:aetros,项目名称:aetros-cli,代码行数:27,代码来源:backend.py

示例3: _save_pip_list

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def _save_pip_list(self, tar):
        '''Dump a pip list containing packages and versions.

        :param dest: unicode -- directory of dumped pip list
        :param tar: tarfile object -- tar where pip list dump will be added
        '''

        pkgs = pip.get_installed_distributions()
        sorted_pkgs = sorted(pkgs, key=lambda pkg: pkg._key)
        sorted_pkg_names = [str(pkg) for pkg in sorted_pkgs]
        pip_list_file = os.path.join(self.tar_dest, 'pip_list.txt')
        with open(pip_list_file, 'w') as pip_file:
            pip_file.write('\n'.join(sorted_pkg_names))
        self._add_file_to_tar(self.tar_dest, 'pip_list.txt', tar)
        os.remove(pip_list_file)
        return sorted_pkgs 
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:18,代码来源:debug_bundler.py

示例4: _save_pip_list

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def _save_pip_list(self, tar):
        '''Dump a pip list, containing packages and versions.

        :param dest: unicode -- directory of dumped pip list
        :param tar: tarfile object -- tar where pip list dump will be added
        '''

        pkgs = pip.get_installed_distributions()
        sorted_pkgs = sorted(pkgs, key=lambda pkg: pkg._key)
        sorted_pkg_names = [str(pkg) for pkg in sorted_pkgs]
        pip_list_file = os.path.join(self.tar_dest, 'pip_list.txt')
        with open(pip_list_file, 'w') as pip_file:
            pip_file.write('\n'.join(sorted_pkg_names))
        self._add_file_to_tar(self.tar_dest, 'pip_list.txt', tar)
        os.remove(pip_list_file)
        return sorted_pkgs 
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:18,代码来源:debug_bundler.py

示例5: check_dependency

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def check_dependency():
    list_deps = []
    missing_deps = []

    with open('requirements.txt') as f:
        list_deps = f.read().splitlines()

    pip_list = sorted([(i.key) for i in pip.get_installed_distributions()])

    for req_dep in list_deps:
        if req_dep not in pip_list:
            missing_deps.append(req_dep)

    if missing_deps:
        print "You are missing a module for Datasploit. Please install them using: "
        print "pip install -r requirements.txt"
        sys.exit() 
开发者ID:dvopsway,项目名称:datasploit,代码行数:19,代码来源:dep_check.py

示例6: can_use_gpu

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def can_use_gpu():
    # Check that 'tensorflow-gpu' is installed on the current code-env
    import pip
    installed_packages = pip.get_installed_distributions()
    return "tensorflow-gpu" in [p.project_name for p in installed_packages]


###################################################################################################################
## FILES LOGIC
################################################################################################################### 
开发者ID:dataiku,项目名称:dataiku-contrib,代码行数:12,代码来源:dl_image_toolbox_utils.py

示例7: _generate_software_info

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def _generate_software_info(self):
        os_version = self._prepare_for_json(platform.platform())
        installed_packages = [self._prepare_for_json(pack) for pack in pip.get_installed_distributions()]
        output = self._run_external_cmd("dpkg-query --list | grep indy")
        indy_packages = output.split(os.linesep)
        return {
            "Software": {
                "OS_version": os_version,
                "Installed_packages": installed_packages,
                # TODO add this field
                "Indy_packages": self._prepare_for_json(indy_packages),
            }
        } 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:15,代码来源:validator_info_tool.py

示例8: get_uninstalled_project_names

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def get_uninstalled_project_names():
    try:
        import pip
        pkg_set = set(KNOWN_PKG_LIST)
        pathmeta_list = pip.get_installed_distributions()
        installed_set = set([meta.project_name for meta in pathmeta_list])
        uninstalled_set = pkg_set.difference(installed_set)
        uninstalled_list = list(uninstalled_set)
    except Exception as ex:
        print(ex)
        uninstalled_list = KNOWN_PKG_LIST
    return uninstalled_list 
开发者ID:Erotemic,项目名称:ibeis,代码行数:14,代码来源:win32bootstrap.py

示例9: get_pip_installed

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def get_pip_installed():
    try:
        import pip
        pypkg_list = [item.key for item in pip.get_installed_distributions()]
        return pypkg_list
    except ImportError:
        #out, err, ret = shell('pip list')
        #if ret == 0:
        #    pypkg_list = [_.split(' ')[0] for  _ in out.split('\n')]
        return [] 
开发者ID:Erotemic,项目名称:ibeis,代码行数:12,代码来源:util_cplat_packages.py

示例10: show_version

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def show_version(scoring_version):
	''' Python version and library versions '''
	swrite('\n=== VERSIONS ===\n\n')
 	# Scoring program version
	swrite("Scoring program version: " + str(scoring_version) + "\n\n")
	# Python version
	swrite("Python version: " + version + "\n\n")
	# Give information on the version installed
	swrite("Versions of libraries installed:\n")
	map(swrite, sorted(["%s==%s\n" % (i.key, i.version) for i in lib()])) 
开发者ID:jamesrobertlloyd,项目名称:automl-phase-2,代码行数:12,代码来源:libscores.py

示例11: show_version

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def show_version():
	# Python version and library versions
	swrite('\n=== VERSIONS ===\n\n')
	# Python version
	swrite("Python version: " + version + "\n\n")
	# Give information on the version installed
	swrite("Versions of libraries installed:\n")
	map(swrite, sorted(["%s==%s\n" % (i.key, i.version) for i in lib()])) 
开发者ID:jamesrobertlloyd,项目名称:automl-phase-2,代码行数:10,代码来源:data_io.py

示例12: _safe_dist

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def _safe_dist():
    for p in pip.get_installed_distributions():
        try:
            yield p.key, p.version
        except Exception:   # pragma    nocover
            pass 
开发者ID:quantmind,项目名称:lux,代码行数:8,代码来源:py.py

示例13: log_running_python_versions

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def log_running_python_versions():
    logging.info("Python version: " + str(sys.version) + ", " + str(sys.version_info))  # () required in Python 3.

    installed_packages = pip.get_installed_distributions()
    installed_packages_list = sorted(["%s==%s" % (i.key, i.version) for i in installed_packages])
    logging.info("Installed Python modules: " + str(installed_packages_list)) 
开发者ID:RoGeorge,项目名称:DS1054Z_screen_capture,代码行数:8,代码来源:Rigol_functions.py

示例14: check_deps

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def check_deps():
    # Fail if the 'co3' module is installed, this supersedes it
    packages = get_installed_distributions(local_only=True)
    # For each EggInfoDistribution, find its metadata
    for pkg in packages:
        try:
            distro = get_distribution(pkg.project_name)
            if distro.project_name == 'co3':
                print("This package replaces the 'co3' distribution.  Please 'pip uninstall co3' first.")
                sys.exit(1)
        except DistributionNotFound:
            pass 
开发者ID:ibmresilient,项目名称:resilient-python-api,代码行数:14,代码来源:setup.py

示例15: check_depdendencies

# 需要导入模块: import pip [as 别名]
# 或者: from pip import get_installed_distributions [as 别名]
def check_depdendencies():
    """
    Makes sure that all required dependencies are installed in the exact version
    (as specified in requirements.txt)
    """
    # Get installed packages
    installed_packages = pip.get_installed_distributions(local_only=False)
    installed_packages_list = sorted(["%s==%s" % (i.key, i.version) for i in installed_packages])

    # Now check if each package specified in requirements.txt is actually installed
    deps_filename = os.path.join(ROOT_INSTALL_PATH, "requirements.txt")
    with open(deps_filename, "r") as f:
        for dep in f.read().split():
            if not dep.lower() in installed_packages_list:
                raise SystemCheckError("Required dependency %s is not installed. Please run 'pip install -e .'" % dep) 
开发者ID:CityOfZion,项目名称:neo-python,代码行数:17,代码来源:Settings.py


注:本文中的pip.get_installed_distributions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。