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


Python utils.get_installed_distributions方法代碼示例

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


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

示例1: run

# 需要導入模塊: from pip import utils [as 別名]
# 或者: from pip.utils import get_installed_distributions [as 別名]
def run(self, options, args):
        dists = get_installed_distributions(local_only=False, skip=())
        missing_reqs_dict, incompatible_reqs_dict = check_requirements(dists)

        for dist in dists:
            key = '%s==%s' % (dist.project_name, dist.version)

            for requirement in missing_reqs_dict.get(key, []):
                logger.info(
                    "%s %s requires %s, which is not installed.",
                    dist.project_name, dist.version, requirement.project_name)

            for requirement, actual in incompatible_reqs_dict.get(key, []):
                logger.info(
                    "%s %s has requirement %s, but you have %s %s.",
                    dist.project_name, dist.version, requirement,
                    actual.project_name, actual.version)

        if missing_reqs_dict or incompatible_reqs_dict:
            return 1
        else:
            logger.info("No broken requirements found.") 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:24,代碼來源:check.py

示例2: main

# 需要導入模塊: from pip import utils [as 別名]
# 或者: from pip.utils import get_installed_distributions [as 別名]
def main():
    parser = argparse.ArgumentParser(description="Read all installed packages from sys.path and list licenses.")
    args = parser.parse_args()

    meta_files_to_check = ['PKG-INFO', 'METADATA']

    for installed_distribution in get_installed_distributions():
        found_license = False
        for metafile in meta_files_to_check:
            if not installed_distribution.has_metadata(metafile):
                continue
            for line in installed_distribution.get_metadata_lines(metafile):
                if 'License: ' in line:
                    (k, v) = line.split(': ', 1)
                    sys.stdout.write("{project_name}: {license}\n".format(
                        project_name=installed_distribution.project_name,
                        license=v))
                    found_license = True
        if not found_license:
            sys.stdout.write("{project_name}: Found no license information.\n".format(
                project_name=installed_distribution.project_name)) 
開發者ID:briandailey,項目名稱:python-packages-license-check,代碼行數:23,代碼來源:check.py

示例3: run_listing

# 需要導入模塊: from pip import utils [as 別名]
# 或者: from pip.utils import get_installed_distributions [as 別名]
def run_listing(self, options):
        installed_packages = get_installed_distributions(
            local_only=options.local,
            user_only=options.user,
        )
        self.output_package_listing(installed_packages) 
開發者ID:chalasr,項目名稱:Flask-P2P,代碼行數:8,代碼來源:list.py

示例4: run_editables

# 需要導入模塊: from pip import utils [as 別名]
# 或者: from pip.utils import get_installed_distributions [as 別名]
def run_editables(self, options):
        installed_packages = get_installed_distributions(
            local_only=options.local,
            user_only=options.user,
            editables_only=True,
        )
        self.output_package_listing(installed_packages) 
開發者ID:chalasr,項目名稱:Flask-P2P,代碼行數:9,代碼來源:list.py

示例5: find_packages_latest_versions

# 需要導入模塊: from pip import utils [as 別名]
# 或者: from pip.utils import get_installed_distributions [as 別名]
def find_packages_latest_versions(self, options):
        index_urls = [options.index_url] + options.extra_index_urls
        if options.no_index:
            logger.info('Ignoring indexes: %s', ','.join(index_urls))
            index_urls = []

        dependency_links = []
        for dist in get_installed_distributions(local_only=options.local,
                                                user_only=options.user):
            if dist.has_metadata('dependency_links.txt'):
                dependency_links.extend(
                    dist.get_metadata_lines('dependency_links.txt'),
                )

        with self._build_session(options) as session:
            finder = self._build_package_finder(options, index_urls, session)
            finder.add_dependency_links(dependency_links)

            installed_packages = get_installed_distributions(
                local_only=options.local,
                user_only=options.user,
                include_editables=False,
            )
            format_control = FormatControl(set(), set())
            wheel_cache = WheelCache(options.cache_dir, format_control)
            for dist in installed_packages:
                req = InstallRequirement.from_line(
                    dist.key, None, isolated=options.isolated_mode,
                    wheel_cache=wheel_cache
                )
                typ = 'unknown'
                try:
                    link = finder.find_requirement(req, True)

                    # If link is None, means installed version is most
                    # up-to-date
                    if link is None:
                        continue
                except DistributionNotFound:
                    continue
                else:
                    canonical_name = pkg_resources.safe_name(req.name).lower()
                    formats = fmt_ctl_formats(format_control, canonical_name)
                    search = Search(
                        req.name,
                        canonical_name,
                        formats)
                    remote_version = finder._link_package_versions(
                        link, search).version
                    if link.is_wheel:
                        typ = 'wheel'
                    else:
                        typ = 'sdist'
                yield dist, remote_version, typ 
開發者ID:chalasr,項目名稱:Flask-P2P,代碼行數:56,代碼來源:list.py


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