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


Python specifiers.SpecifierSet方法代碼示例

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


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

示例1: check_requires_python

# 需要導入模塊: from pip._vendor.packaging import specifiers [as 別名]
# 或者: from pip._vendor.packaging.specifiers import SpecifierSet [as 別名]
def check_requires_python(requires_python):
    """
    Check if the python version in use match the `requires_python` specifier.

    Returns `True` if the version of python in use matches the requirement.
    Returns `False` if the version of python in use does not matches the
    requirement.

    Raises an InvalidSpecifier if `requires_python` have an invalid format.
    """
    if requires_python is None:
        # The package provides no information
        return True
    requires_python_specifier = specifiers.SpecifierSet(requires_python)

    # We only use major.minor.micro
    python_version = version.parse('.'.join(map(str, sys.version_info[:3])))
    return python_version in requires_python_specifier 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:20,代碼來源:packaging.py

示例2: is_superset

# 需要導入模塊: from pip._vendor.packaging import specifiers [as 別名]
# 或者: from pip._vendor.packaging.specifiers import SpecifierSet [as 別名]
def is_superset(self, other: Union[str, SpecifierSet]) -> bool:
        if self.is_impossible:
            return False
        if self.is_allow_all:
            return True
        other = type(self)(str(other))
        if other._upper_bound[0] >= self.MAX_MAJOR_VERSION:
            # XXX: narrow down the upper bound to ``MAX_MAJOR_VERSION``
            # So that `>=3.6,<4.0` is considered a superset of `>=3.7`, see issues/66
            other._upper_bound = (self.MAX_MAJOR_VERSION, 0, 0)
        if (
            self._lower_bound > other._lower_bound
            or self._upper_bound < other._upper_bound
        ):
            return False
        valid_excludes = set(
            _restrict_versions_to_range(
                self._excludes, other._lower_bound, other._upper_bound
            )
        )
        return valid_excludes <= set(other._excludes) 
開發者ID:frostming,項目名稱:pdm,代碼行數:23,代碼來源:specifiers.py

示例3: is_subset

# 需要導入模塊: from pip._vendor.packaging import specifiers [as 別名]
# 或者: from pip._vendor.packaging.specifiers import SpecifierSet [as 別名]
def is_subset(self, other: Union[str, SpecifierSet]) -> bool:
        if self.is_impossible:
            return False
        other = type(self)(str(other))
        if other._upper_bound[0] >= self.MAX_MAJOR_VERSION:
            other._upper_bound = self.MAX_VERSION
        if other.is_allow_all:
            return True
        if (
            self._lower_bound < other._lower_bound
            or self._upper_bound > other._upper_bound
        ):
            return False
        valid_excludes = set(
            _restrict_versions_to_range(
                other._excludes, self._lower_bound, self._upper_bound
            )
        )
        return valid_excludes <= set(self._excludes) 
開發者ID:frostming,項目名稱:pdm,代碼行數:21,代碼來源:specifiers.py

示例4: find_candidates

# 需要導入模塊: from pip._vendor.packaging import specifiers [as 別名]
# 或者: from pip._vendor.packaging.specifiers import SpecifierSet [as 別名]
def find_candidates(
        self,
        project_name,       # type: str
        specifier=None,     # type: Optional[specifiers.BaseSpecifier]
    ):
        """Find matches for the given project and specifier.

        If given, `specifier` should implement `filter` to allow version
        filtering (e.g. ``packaging.specifiers.SpecifierSet``).

        Returns a `FoundCandidates` instance.
        """
        if specifier is None:
            specifier = specifiers.SpecifierSet()
        return FoundCandidates.from_specifier(
            self.find_all_candidates(project_name),
            specifier=specifier,
            prereleases=(self.allow_all_prereleases or None),
            evaluator=self.candidate_evaluator,
        ) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:22,代碼來源:index.py

示例5: check_requires_python

# 需要導入模塊: from pip._vendor.packaging import specifiers [as 別名]
# 或者: from pip._vendor.packaging.specifiers import SpecifierSet [as 別名]
def check_requires_python(requires_python):
    # type: (Optional[str]) -> bool
    """
    Check if the python version in use match the `requires_python` specifier.

    Returns `True` if the version of python in use matches the requirement.
    Returns `False` if the version of python in use does not matches the
    requirement.

    Raises an InvalidSpecifier if `requires_python` have an invalid format.
    """
    if requires_python is None:
        # The package provides no information
        return True
    requires_python_specifier = specifiers.SpecifierSet(requires_python)

    # We only use major.minor.micro
    python_version = version.parse('.'.join(map(str, sys.version_info[:3])))
    return python_version in requires_python_specifier 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:21,代碼來源:packaging.py

示例6: check_requires_python

# 需要導入模塊: from pip._vendor.packaging import specifiers [as 別名]
# 或者: from pip._vendor.packaging.specifiers import SpecifierSet [as 別名]
def check_requires_python(requires_python, version_info):
    # type: (Optional[str], Tuple[int, ...]) -> bool
    """
    Check if the given Python version matches a "Requires-Python" specifier.

    :param version_info: A 3-tuple of ints representing a Python
        major-minor-micro version to check (e.g. `sys.version_info[:3]`).

    :return: `True` if the given Python version satisfies the requirement.
        Otherwise, return `False`.

    :raises InvalidSpecifier: If `requires_python` has an invalid format.
    """
    if requires_python is None:
        # The package provides no information
        return True
    requires_python_specifier = specifiers.SpecifierSet(requires_python)

    python_version = version.parse('.'.join(map(str, version_info)))
    return python_version in requires_python_specifier 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:22,代碼來源:packaging.py

示例7: find_best_candidate

# 需要導入模塊: from pip._vendor.packaging import specifiers [as 別名]
# 或者: from pip._vendor.packaging.specifiers import SpecifierSet [as 別名]
def find_best_candidate(
        self,
        project_name,       # type: str
        specifier=None,     # type: Optional[specifiers.BaseSpecifier]
        hashes=None,        # type: Optional[Hashes]
    ):
        # type: (...) -> BestCandidateResult
        """Find matches for the given project and specifier.

        :param specifier: An optional object implementing `filter`
            (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable
            versions.

        :return: A `BestCandidateResult` instance.
        """
        candidates = self.find_all_candidates(project_name)
        candidate_evaluator = self.make_candidate_evaluator(
            project_name=project_name,
            specifier=specifier,
            hashes=hashes,
        )
        return candidate_evaluator.compute_best_candidate(candidates) 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:24,代碼來源:package_finder.py


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