当前位置: 首页>>代码示例>>Python>>正文


Python version.parse方法代码示例

本文整理汇总了Python中pip._vendor.packaging.version.parse方法的典型用法代码示例。如果您正苦于以下问题:Python version.parse方法的具体用法?Python version.parse怎么用?Python version.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip._vendor.packaging.version的用法示例。


在下文中一共展示了version.parse方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_version

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [as 别名]
def check_version(version):
    """Return version of package on pypi.python.org using json."""

    def check(version):
        try:
            url_pattern = 'https://pypi.python.org/pypi/mdeepctr/json'
            req = requests.get(url_pattern)
            latest_version = parse('0')
            version = parse(version)
            if req.status_code == requests.codes.ok:
                j = json.loads(req.text.encode('utf-8'))
                releases = j.get('releases', [])
                for release in releases:
                    ver = parse(release)
                    if not ver.is_prerelease:
                        latest_version = max(latest_version, ver)
                if latest_version > version:
                    logging.warning('\nDeepCTR version {0} detected. Your version is {1}.\nUse `pip install -U mdeepctr` to upgrade.Changelog: https://github.com/shenweichen/DeepCTR/releases/tag/v{0}'.format(
                        latest_version, version))
        except Exception:
            return
    Thread(target=check, args=(version,)).start() 
开发者ID:ShenDezhou,项目名称:icme2019,代码行数:24,代码来源:utils.py

示例2: check_requires_python

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [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

示例3: check_requires_python

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [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

示例4: check_requires_python

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [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

示例5: _set_requirement

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [as 别名]
def _set_requirement(self):
        # type: () -> None
        """Set requirement after generating metadata.
        """
        assert self.req is None
        assert self.metadata is not None
        assert self.source_dir is not None

        # Construct a Requirement object from the generated metadata
        if isinstance(parse_version(self.metadata["Version"]), Version):
            op = "=="
        else:
            op = "==="

        self.req = Requirement(
            "".join([
                self.metadata["Name"],
                op,
                self.metadata["Version"],
            ])
        ) 
开发者ID:pantsbuild,项目名称:pex,代码行数:23,代码来源:req_install.py

示例6: highest_version

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [as 别名]
def highest_version(versions):
    return max(versions, key=parse_version) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:search.py

示例7: __init__

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [as 别名]
def __init__(self, project, version, location):
        self.project = project
        self.version = parse_version(version)
        self.location = location
        self._key = (self.project, self.version, self.location) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:index.py

示例8: get_git_version

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [as 别名]
def get_git_version(self):
        VERSION_PFX = 'git version '
        version = self.run_command(['version'], show_stdout=False)
        if version.startswith(VERSION_PFX):
            version = version[len(VERSION_PFX):]
        else:
            version = ''
        # get first 3 positions of the git version becasue
        # on windows it is x.y.z.windows.t, and this parses as
        # LegacyVersion which always smaller than a Version.
        version = '.'.join(version.split('.')[:3])
        return parse_version(version) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:git.py

示例9: check_version

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [as 别名]
def check_version(version):
    """Return version of package on pypi.python.org using json."""

    def check(version):
        try:
            url_pattern = 'https://pypi.python.org/pypi/deepctr-torch/json'
            req = requests.get(url_pattern)
            latest_version = parse('0')
            version = parse(version)
            if req.status_code == requests.codes.ok:
                j = json.loads(req.text.encode('utf-8'))
                releases = j.get('releases', [])
                for release in releases:
                    ver = parse(release)
                    if ver.is_prerelease or  ver.is_postrelease:
                        continue
                    latest_version = max(latest_version, ver)
                if latest_version > version:
                    logging.warning(
                        '\nDeepCTR-PyTorch version {0} detected. Your version is {1}.\nUse `pip install -U deepctr-torch` to upgrade.Changelog: https://github.com/shenweichen/DeepCTR-Torch/releases/tag/v{0}'.format(
                            latest_version, version))
        except :
            print("Please check the latest version manually on https://pypi.org/project/deepctr-torch/#history")
            return

    Thread(target=check, args=(version,)).start() 
开发者ID:shenweichen,项目名称:DeepCTR-Torch,代码行数:28,代码来源:utils.py

示例10: get_git_version

# 需要导入模块: from pip._vendor.packaging import version [as 别名]
# 或者: from pip._vendor.packaging.version import parse [as 别名]
def get_git_version(self):
        VERSION_PFX = 'git version '
        version = self.run_command(['version'], show_stdout=False)
        if version.startswith(VERSION_PFX):
            version = version[len(VERSION_PFX):].split()[0]
        else:
            version = ''
        # get first 3 positions of the git version becasue
        # on windows it is x.y.z.windows.t, and this parses as
        # LegacyVersion which always smaller than a Version.
        version = '.'.join(version.split('.')[:3])
        return parse_version(version) 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:14,代码来源:git.py


注:本文中的pip._vendor.packaging.version.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。