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


Python req.RequirementSet方法代碼示例

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


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

示例1: resolve_reqs

# 需要導入模塊: from pip._internal import req [as 別名]
# 或者: from pip._internal.req import RequirementSet [as 別名]
def resolve_reqs(self, download_dir, ireq, wheel_cache):
        with get_requirement_tracker() as req_tracker, TempDirectory(
            kind="resolver"
        ) as temp_dir, indent_log():
            preparer = self.command.make_requirement_preparer(
                temp_build_dir=temp_dir,
                options=self.options,
                req_tracker=req_tracker,
                session=self.session,
                finder=self.finder,
                use_user_site=False,
                download_dir=download_dir,
                wheel_download_dir=self._wheel_download_dir,
            )

            reqset = RequirementSet()
            ireq.is_direct = True
            reqset.add_requirement(ireq)

            resolver = self.command.make_resolver(
                preparer=preparer,
                finder=self.finder,
                options=self.options,
                wheel_cache=wheel_cache,
                use_user_site=False,
                ignore_installed=True,
                ignore_requires_python=False,
                force_reinstall=False,
                upgrade_strategy="to-satisfy-only",
            )
            results = resolver._resolve_one(reqset, ireq)
            if not ireq.prepared:
                # If still not prepared, e.g. a constraint, do enough to assign
                # the ireq a name:
                resolver._get_abstract_dist_for(ireq)

            if PIP_VERSION[:2] <= (20, 0):
                reqset.cleanup_files()

        return set(results) 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:42,代碼來源:pypi.py

示例2: warn_deprecated_install_options

# 需要導入模塊: from pip._internal import req [as 別名]
# 或者: from pip._internal.req import RequirementSet [as 別名]
def warn_deprecated_install_options(requirement_set, options):
    # type: (RequirementSet, Optional[List[str]]) -> None
    """If any location-changing --install-option arguments were passed for
    requirements or on the command-line, then show a deprecation warning.
    """
    def format_options(option_names):
        # type: (Iterable[str]) -> List[str]
        return ["--{}".format(name.replace("_", "-")) for name in option_names]

    requirements = (
        requirement_set.unnamed_requirements +
        list(requirement_set.requirements.values())
    )

    offenders = []

    for requirement in requirements:
        install_options = requirement.options.get("install_options", [])
        location_options = parse_distutils_args(install_options)
        if location_options:
            offenders.append(
                "{!r} from {}".format(
                    format_options(location_options.keys()), requirement
                )
            )

    if options:
        location_options = parse_distutils_args(options)
        if location_options:
            offenders.append(
                "{!r} from command line".format(
                    format_options(location_options.keys())
                )
            )

    if not offenders:
        return

    deprecated(
        reason=(
            "Location-changing options found in --install-option: {}. "
            "This configuration may cause unexpected behavior and is "
            "unsupported.".format(
                "; ".join(offenders)
            )
        ),
        replacement=(
            "using pip-level options like --user, --prefix, --root, and "
            "--target"
        ),
        gone_in="20.2",
        issue=7309,
    ) 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:55,代碼來源:install.py


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