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


Python packaging.check_requires_python方法代碼示例

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


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

示例1: _check_link_requires_python

# 需要導入模塊: from pip._internal.utils import packaging [as 別名]
# 或者: from pip._internal.utils.packaging import check_requires_python [as 別名]
def _check_link_requires_python(
    link,  # type: Link
    version_info,  # type: Tuple[int, int, int]
    ignore_requires_python=False,  # type: bool
):
    # type: (...) -> bool
    """
    Return whether the given Python version is compatible with a link's
    "Requires-Python" value.

    :param version_info: A 3-tuple of ints representing the Python
        major-minor-micro version to check.
    :param ignore_requires_python: Whether to ignore the "Requires-Python"
        value if the given Python version isn't compatible.
    """
    try:
        is_compatible = check_requires_python(
            link.requires_python, version_info=version_info,
        )
    except specifiers.InvalidSpecifier:
        logger.debug(
            "Ignoring invalid Requires-Python (%r) for link: %s",
            link.requires_python, link,
        )
    else:
        if not is_compatible:
            version = '.'.join(map(str, version_info))
            if not ignore_requires_python:
                logger.debug(
                    'Link requires a different Python (%s not in: %r): %s',
                    version, link.requires_python, link,
                )
                return False

            logger.debug(
                'Ignoring failed Requires-Python check (%s not in: %r) '
                'for link: %s',
                version, link.requires_python, link,
            )

    return True 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:43,代碼來源:package_finder.py


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