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


Python misc.get_installed_distributions方法代码示例

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


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

示例1: collect_loaded_packages

# 需要导入模块: from pip._internal.utils import misc [as 别名]
# 或者: from pip._internal.utils.misc 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: create_package_set_from_installed

# 需要导入模块: from pip._internal.utils import misc [as 别名]
# 或者: from pip._internal.utils.misc import get_installed_distributions [as 别名]
def create_package_set_from_installed(**kwargs):
    # type: (**Any) -> Tuple[PackageSet, bool]
    """Converts a list of distributions into a PackageSet.
    """
    # Default to using all packages installed on the system
    if kwargs == {}:
        kwargs = {"local_only": False, "skip": ()}

    package_set = {}
    problems = False
    for dist in get_installed_distributions(**kwargs):
        name = canonicalize_name(dist.project_name)
        try:
            package_set[name] = PackageDetails(dist.version, dist.requires())
        except RequirementParseError as e:
            # Don't crash on broken metadata
            logging.warning("Error parsing requirements for %s: %s", name, e)
            problems = True
    return package_set, problems 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:21,代码来源:check.py

示例3: create_package_set_from_installed

# 需要导入模块: from pip._internal.utils import misc [as 别名]
# 或者: from pip._internal.utils.misc import get_installed_distributions [as 别名]
def create_package_set_from_installed(**kwargs):
    # type: (**Any) -> Tuple[PackageSet, bool]
    """Converts a list of distributions into a PackageSet.
    """
    # Default to using all packages installed on the system
    if kwargs == {}:
        kwargs = {"local_only": False, "skip": ()}

    package_set = {}
    problems = False
    for dist in get_installed_distributions(**kwargs):
        name = canonicalize_name(dist.project_name)
        try:
            package_set[name] = PackageDetails(dist.version, dist.requires())
        except RequirementParseError as e:
            # Don't crash on broken metadata
            logger.warning("Error parsing requirements for %s: %s", name, e)
            problems = True
    return package_set, problems 
开发者ID:ali5h,项目名称:rules_pip,代码行数:21,代码来源:check.py

示例4: create_package_set_from_installed

# 需要导入模块: from pip._internal.utils import misc [as 别名]
# 或者: from pip._internal.utils.misc import get_installed_distributions [as 别名]
def create_package_set_from_installed(**kwargs):
    # type: (**Any) -> PackageSet
    """Converts a list of distributions into a PackageSet.
    """
    # Default to using all packages installed on the system
    if kwargs == {}:
        kwargs = {"local_only": False, "skip": ()}
    retval = {}
    for dist in get_installed_distributions(**kwargs):
        name = canonicalize_name(dist.project_name)
        retval[name] = PackageDetails(dist.version, dist.requires())
    return retval 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:14,代码来源:check.py

示例5: create_package_set_from_installed

# 需要导入模块: from pip._internal.utils import misc [as 别名]
# 或者: from pip._internal.utils.misc import get_installed_distributions [as 别名]
def create_package_set_from_installed(**kwargs):
    # type: (**Any) -> PackageSet
    """Converts a list of distributions into a PackageSet.
    """
    # Default to using all packages installed on the system
    if kwargs == {}:
        kwargs = {"local_only": False, "skip": ()}

    package_set = {}
    for dist in get_installed_distributions(**kwargs):
        name = canonicalize_name(dist.project_name)
        package_set[name] = PackageDetails(dist.version, dist.requires())
    return package_set 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:15,代码来源:check.py

示例6: check_deps

# 需要导入模块: from pip._internal.utils import misc [as 别名]
# 或者: from pip._internal.utils.misc 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


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