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