Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:infrastructure:pagure
python-python-jenkins
use-parts-of-legacy-version.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File use-parts-of-legacy-version.patch of Package python-python-jenkins
Index: python-jenkins-1.8.0/jenkins/plugins.py =================================================================== --- python-jenkins-1.8.0.orig/jenkins/plugins.py +++ python-jenkins-1.8.0/jenkins/plugins.py @@ -41,8 +41,7 @@ import operator import re - -import pkg_resources +from typing import Iterator, Tuple class Plugin(dict): @@ -67,6 +66,63 @@ class Plugin(dict): super(Plugin, self).__setitem__(key, value) +# Portion of code from packaging module, dual licensed under the terms of +# the Apache License, Version 2.0, and the BSD License. +_legacy_version_component_re = re.compile(r"(\d+ | [a-z]+ | \.| -)", re.VERBOSE) + +_legacy_version_replacement_map = { + "pre": "c", + "preview": "c", + "-": "final-", + "rc": "c", + "dev": "@", +} + + +def _parse_version_parts(s: str) -> Iterator[str]: + for part in _legacy_version_component_re.split(s): + part = _legacy_version_replacement_map.get(part, part) + + if not part or part == ".": + continue + + if part[:1] in "0123456789": + # pad for numeric comparison + yield part.zfill(8) + else: + yield "*" + part + + # ensure that alpha/beta/candidate are before final + yield "*final" + + +def _legacy_cmpkey(version: str) -> Tuple[int, Tuple[str, ...]]: + + # We hardcode an epoch of -1 here. A PEP 440 version can only have a epoch + # greater than or equal to 0. This will effectively put the LegacyVersion, + # which uses the defacto standard originally implemented by setuptools, + # as before all PEP 440 versions. + epoch = -1 + + # This scheme is taken from pkg_resources.parse_version setuptools prior to + # it's adoption of the packaging library. + parts: List[str] = [] + for part in _parse_version_parts(version.lower()): + if part.startswith("*"): + # remove "-" before a prerelease tag + if part < "*final": + while parts and parts[-1] == "*final-": + parts.pop() + + # remove trailing zeros from each series of numeric parts + while parts and parts[-1] == "00000000": + parts.pop() + + parts.append(part) + + return epoch, tuple(parts) + + class PluginVersion(str): '''Class providing comparison capabilities for plugin versions.''' @@ -76,15 +132,14 @@ class PluginVersion(str): '''Parse plugin version and store it for comparison.''' self._version = version - self.parsed_version = pkg_resources.parse_version( - self.__convert_version(version)) + self.parsed_version = _legacy_cmpkey(self.__convert_version(version)) def __convert_version(self, version): return self._VERSION_RE.sub(r'\g<1>.preview', str(version)) def __compare(self, op, version): - return op(self.parsed_version, pkg_resources.parse_version( - self.__convert_version(version))) + return op(self.parsed_version, + _legacy_cmpkey(self.__convert_version(version))) def __le__(self, version): return self.__compare(operator.le, version) Index: python-jenkins-1.8.0/requirements.txt =================================================================== --- python-jenkins-1.8.0.orig/requirements.txt +++ python-jenkins-1.8.0/requirements.txt @@ -1,5 +1,3 @@ -# Setuptools removed support for PEP 440 non-conforming versions -setuptools<66 six>=1.3.0 pbr>=0.8.2 multi_key_dict
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor