當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。