14
0

- Update to 1.8.0:

* Add retrieval of stages of artifacts
  * Switch links to opendev.org
  * Allow build number to be a string
  * Use fullname in get_job_info_regex
- Add patch use-parts-of-legacy-version.patch:
  * Use underpining parts of LegacyVersion pre-removal.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-jenkins?expand=0&rev=34
This commit is contained in:
2023-04-17 05:04:51 +00:00
committed by Git OBS Bridge
parent a41675fb7f
commit fb1d68a048
5 changed files with 108 additions and 97 deletions

View File

@@ -1,46 +0,0 @@
---
jenkins/plugins.py | 5 +++--
requirements.txt | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
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
@@ -43,6 +43,7 @@ import operator
import re
import pkg_resources
+import packaging.version
class Plugin(dict):
@@ -76,14 +77,14 @@ class PluginVersion(str):
'''Parse plugin version and store it for comparison.'''
self._version = version
- self.parsed_version = pkg_resources.parse_version(
+ self.parsed_version = packaging.version.parse(
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(
+ return op(self.parsed_version, packaging.version.parse(
self.__convert_version(version)))
def __le__(self, 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,5 @@
-# Setuptools removed support for PEP 440 non-conforming versions
-setuptools<66
+setuptools
+packaging
six>=1.3.0
pbr>=0.8.2
multi_key_dict

View File

@@ -1,9 +1,13 @@
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Apr 12 15:02:56 UTC 2023 - Matej Cepl <mcepl@suse.com> Mon Apr 17 05:03:59 UTC 2023 - Steve Kowalik <steven.kowalik@suse.com>
- Add skip_failing_tests.patch - Update to 1.8.0:
- Add pkg_resources.patch (lp#2003556) to use packaging instead * Add retrieval of stages of artifacts
of obsolete version of pkg_resources. * Switch links to opendev.org
* Allow build number to be a string
* Use fullname in get_job_info_regex
- Add patch use-parts-of-legacy-version.patch:
* Use underpining parts of LegacyVersion pre-removal.
------------------------------------------------------------------- -------------------------------------------------------------------
Wed May 4 05:46:39 UTC 2022 - pgajdos@suse.com Wed May 4 05:46:39 UTC 2022 - pgajdos@suse.com

View File

@@ -22,17 +22,13 @@ Version: 1.8.0
Release: 0 Release: 0
Summary: Python bindings for the remote Jenkins API Summary: Python bindings for the remote Jenkins API
License: BSD-3-Clause License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://opendev.org/jjb/python-jenkins URL: https://opendev.org/jjb/python-jenkins
Source: https://files.pythonhosted.org/packages/source/p/python-jenkins/python-jenkins-%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/p/python-jenkins/python-jenkins-%{version}.tar.gz
# https://bugs.launchpad.net/python-jenkins/+bug/1971524 # https://bugs.launchpad.net/python-jenkins/+bug/1971524
Patch0: python-python-jenkins-no-mock.patch Patch0: python-python-jenkins-no-mock.patch
# PATCH-FIX-UPSTREAM pkg_resources.patch lp#2003556 mcepl@suse.com # PATCH-FIX-OPENSUSE Upstream are arguing about version parsing, use the
# Don't depend on the old version of setuptools, but use packaging # underlying parts of LegacyVersion from packaging pre-removal
Patch1: pkg_resources.patch Patch1: use-parts-of-legacy-version.patch
# PATCH-FIX-OPENSUSE skip_failing_tests.patch bsc#[0-9]+ mcepl@suse.com
# skip failing tests (upstream just up-versioned setuptools and cannot be bothered)
Patch2: skip_failing_tests.patch
BuildRequires: %{python_module cmd2} BuildRequires: %{python_module cmd2}
BuildRequires: %{python_module multi_key_dict} BuildRequires: %{python_module multi_key_dict}
BuildRequires: %{python_module packaging} BuildRequires: %{python_module packaging}

View File

@@ -1,40 +0,0 @@
---
tests/test_plugins.py | 4 ++++
1 file changed, 4 insertions(+)
Index: python-jenkins-1.8.0/tests/test_plugins.py
===================================================================
--- python-jenkins-1.8.0.orig/tests/test_plugins.py
+++ python-jenkins-1.8.0/tests/test_plugins.py
@@ -33,6 +33,7 @@
import json
from unittest.mock import patch
+from unittest import skip
from testscenarios.scenarios import multiply_scenarios
import jenkins
@@ -282,6 +283,7 @@ class PluginsTestScenarios(JenkinsPlugin
self.addCleanup(patcher.stop)
self.jenkins_mock.return_value = json.dumps(plugin_info_json)
+ @skip("Failing with modern setuptools")
def test_plugin_version_comparison(self):
"""Verify that valid versions are ordinally correct.
@@ -300,6 +302,7 @@ class PluginsTestScenarios(JenkinsPlugin
"when comparing versions!"
.format(v1, self.v2, self.op))
+ @skip("Failing with modern setuptools")
def test_plugin_version_object_comparison(self):
"""Verify use of PluginVersion for comparison
@@ -320,6 +323,7 @@ class PluginsTestScenarios(JenkinsPlugin
.format(v1, v2, self.op))
+@skip("Failing with modern setuptools")
class PluginsTest(JenkinsPluginsBase):
def test_plugin_equal(self):

View File

@@ -0,0 +1,97 @@
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)