當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。