当前位置: 首页>>代码示例>>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;未经允许,请勿转载。