diff --git a/python-rpm-generators.spec b/python-rpm-generators.spec index 3a264b0..c61d9c1 100644 --- a/python-rpm-generators.spec +++ b/python-rpm-generators.spec @@ -1,7 +1,7 @@ Name: python-rpm-generators Summary: Dependency generators for Python RPMs Version: 12 -Release: 8%{?dist} +Release: 9%{?dist} # Originally all those files were part of RPM, so license is kept here License: GPLv2+ @@ -47,6 +47,10 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py %{_rpmconfigdir}/pythonbundles.py %changelog +* Thu Oct 28 2021 Gordon Messmer - 12-9 +- Sync dependency conversion with upstream pyreq2rpm. +- Improve handling of > and < operators, and != operator with prefix matching + * Fri Jul 23 2021 Fedora Release Engineering - 12-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild diff --git a/pythondistdeps.py b/pythondistdeps.py index e8b5afd..eea2628 100755 --- a/pythondistdeps.py +++ b/pythondistdeps.py @@ -134,6 +134,9 @@ class RpmVersion(): self.pre = version._version.pre self.dev = version._version.dev self.post = version._version.post + # version.local is ignored as it is not expected to appear + # in public releases + # https://www.python.org/dev/peps/pep-0440/#local-version-identifiers def increment(self): self.version[-1] += 1 @@ -201,18 +204,27 @@ def convert_not_equal(name, operator, version_id): if version_id.endswith('.*'): version_id = version_id[:-2] version = RpmVersion(version_id) - lower_version = RpmVersion(version_id).increment() + version_gt = RpmVersion(version_id).increment() + version_gt_operator = '>=' + # Prevent pre-releases from satisfying a < requirement + version = '{}~'.format(version) else: version = RpmVersion(version_id) - lower_version = version - return '({} < {} or {} > {})'.format( - name, version, name, lower_version) + version_gt = version + version_gt_operator = '>' + return '({} < {} or {} {} {})'.format( + name, version, name, version_gt_operator, version_gt) def convert_ordered(name, operator, version_id): if version_id.endswith('.*'): # PEP 440 does not define semantics for prefix matching # with ordered comparisons + # see: https://github.com/pypa/packaging/issues/320 + # and: https://github.com/pypa/packaging/issues/321 + # This style of specifier is officially "unsupported", + # even though it is processed. Support may be removed + # in version 21.0. version_id = version_id[:-2] version = RpmVersion(version_id) if operator == '>': @@ -223,6 +235,12 @@ def convert_ordered(name, operator, version_id): operator = '<' else: version = RpmVersion(version_id) + # Prevent pre-releases from satisfying a < requirement + if operator == '<' and not version.pre and not version.dev and not version.post: + version = '{}~'.format(version) + # Prevent post-releases from satisfying a > requirement + if operator == '>' and not version.pre and not version.dev and not version.post: + version = '{}.0'.format(version) return '{} {} {}'.format(name, operator, version) diff --git a/tests/data/scripts_pythondistdeps/test-data.yaml b/tests/data/scripts_pythondistdeps/test-data.yaml index afd928e..baad647 100644 --- a/tests/data/scripts_pythondistdeps/test-data.yaml +++ b/tests/data/scripts_pythondistdeps/test-data.yaml @@ -28,7 +28,7 @@ python2.7dist(setuptools) >= 21 python2.7dist(six) >= 1.9 python2.7dist(urllib3) >= 1.24.2 - ((python2.7dist(websocket-client) < 0.40 or python2.7dist(websocket-client) > 0.40) with (python2.7dist(websocket-client) < 0.41 or python2.7dist(websocket-client) > 0.42) with (python2.7dist(websocket-client) < 0.42 or python2.7dist(websocket-client) > 0.43) with python2.7dist(websocket-client) >= 0.32) + ((python2.7dist(websocket-client) < 0.40 or python2.7dist(websocket-client) > 0.40) with (python2.7dist(websocket-client) < 0.41~ or python2.7dist(websocket-client) >= 0.42) with (python2.7dist(websocket-client) < 0.42~ or python2.7dist(websocket-client) >= 0.43) with python2.7dist(websocket-client) >= 0.32) usr/lib/python2.7/site-packages/mistune-0.8.4-py2.7.egg-info: provides: |- python2.7dist(mistune) = 0.8.4 @@ -75,12 +75,12 @@ python2dist(tox) = 3.14 requires: |- python(abi) = 2.7 - (python2.7dist(filelock) < 4 with python2.7dist(filelock) >= 3) - (python2.7dist(importlib-metadata) < 1 with python2.7dist(importlib-metadata) >= 0.12) + (python2.7dist(filelock) < 4~ with python2.7dist(filelock) >= 3) + (python2.7dist(importlib-metadata) < 1~ with python2.7dist(importlib-metadata) >= 0.12) python2.7dist(packaging) >= 14 - (python2.7dist(pluggy) < 1 with python2.7dist(pluggy) >= 0.12) - (python2.7dist(py) < 2 with python2.7dist(py) >= 1.4.17) - (python2.7dist(six) < 2 with python2.7dist(six) >= 1) + (python2.7dist(pluggy) < 1~ with python2.7dist(pluggy) >= 0.12) + (python2.7dist(py) < 2~ with python2.7dist(py) >= 1.4.17) + (python2.7dist(six) < 2~ with python2.7dist(six) >= 1) python2.7dist(toml) >= 0.9.4 python2.7dist(virtualenv) >= 14 usr/lib/python2.7/site-packages/urllib3-1.25.7-py2.7.egg-info: @@ -105,7 +105,7 @@ python(abi) = 3.7 (python3.7dist(lazy-object-proxy) >= 1.4 with python3.7dist(lazy-object-proxy) < 1.5) (python3.7dist(six) >= 1.12 with python3.7dist(six) < 2) - (python3.7dist(typed-ast) < 1.5 with python3.7dist(typed-ast) >= 1.4) + (python3.7dist(typed-ast) < 1.5~ with python3.7dist(typed-ast) >= 1.4) (python3.7dist(wrapt) >= 1.11 with python3.7dist(wrapt) < 1.12) usr/lib/python3.7/site-packages/packaging-19.0.dist-info: provides: |- @@ -148,12 +148,12 @@ python3dist(tox) = 3.14 requires: |- python(abi) = 3.7 - (python3.7dist(filelock) < 4 with python3.7dist(filelock) >= 3) - (python3.7dist(importlib-metadata) < 1 with python3.7dist(importlib-metadata) >= 0.12) + (python3.7dist(filelock) < 4~ with python3.7dist(filelock) >= 3) + (python3.7dist(importlib-metadata) < 1~ with python3.7dist(importlib-metadata) >= 0.12) python3.7dist(packaging) >= 14 - (python3.7dist(pluggy) < 1 with python3.7dist(pluggy) >= 0.12) - (python3.7dist(py) < 2 with python3.7dist(py) >= 1.4.17) - (python3.7dist(six) < 2 with python3.7dist(six) >= 1) + (python3.7dist(pluggy) < 1~ with python3.7dist(pluggy) >= 0.12) + (python3.7dist(py) < 2~ with python3.7dist(py) >= 1.4.17) + (python3.7dist(six) < 2~ with python3.7dist(six) >= 1) python3.7dist(toml) >= 0.9.4 python3.7dist(virtualenv) >= 14 usr/lib/python3.9/site-packages/astroid-2.3.3.dist-info: @@ -205,7 +205,7 @@ python3.9dist(setuptools) >= 21 python3.9dist(six) >= 1.9 python3.9dist(urllib3) >= 1.24.2 - ((python3.9dist(websocket-client) < 0.40 or python3.9dist(websocket-client) > 0.40) with (python3.9dist(websocket-client) < 0.41 or python3.9dist(websocket-client) > 0.42) with (python3.9dist(websocket-client) < 0.42 or python3.9dist(websocket-client) > 0.43) with python3.9dist(websocket-client) >= 0.32) + ((python3.9dist(websocket-client) < 0.40 or python3.9dist(websocket-client) > 0.40) with (python3.9dist(websocket-client) < 0.41~ or python3.9dist(websocket-client) >= 0.42) with (python3.9dist(websocket-client) < 0.42~ or python3.9dist(websocket-client) >= 0.43) with python3.9dist(websocket-client) >= 0.32) usr/lib/python3.9/site-packages/mistune-0.8.4-py3.9.egg-info: provides: |- python3.9dist(mistune) = 0.8.4 @@ -260,11 +260,11 @@ python3dist(tox) = 3.14 requires: |- python(abi) = 3.9 - (python3.9dist(filelock) < 4 with python3.9dist(filelock) >= 3) + (python3.9dist(filelock) < 4~ with python3.9dist(filelock) >= 3) python3.9dist(packaging) >= 14 - (python3.9dist(pluggy) < 1 with python3.9dist(pluggy) >= 0.12) - (python3.9dist(py) < 2 with python3.9dist(py) >= 1.4.17) - (python3.9dist(six) < 2 with python3.9dist(six) >= 1) + (python3.9dist(pluggy) < 1~ with python3.9dist(pluggy) >= 0.12) + (python3.9dist(py) < 2~ with python3.9dist(py) >= 1.4.17) + (python3.9dist(six) < 2~ with python3.9dist(six) >= 1) python3.9dist(toml) >= 0.9.4 python3.9dist(virtualenv) >= 14 usr/lib/python3.9/site-packages/urllib3-1.25.7-py3.9.egg-info: @@ -437,7 +437,7 @@ python2.7dist(setuptools) >= 21 python2.7dist(six) >= 1.9 python2.7dist(urllib3) >= 1.24.2 - ((python2.7dist(websocket-client) < 0.40 or python2.7dist(websocket-client) > 0.40) with (python2.7dist(websocket-client) < 0.41 or python2.7dist(websocket-client) > 0.42) with (python2.7dist(websocket-client) < 0.42 or python2.7dist(websocket-client) > 0.43) with python2.7dist(websocket-client) >= 0.32) + ((python2.7dist(websocket-client) < 0.40 or python2.7dist(websocket-client) > 0.40) with (python2.7dist(websocket-client) < 0.41~ or python2.7dist(websocket-client) >= 0.42) with (python2.7dist(websocket-client) < 0.42~ or python2.7dist(websocket-client) >= 0.43) with python2.7dist(websocket-client) >= 0.32) usr/lib/python2.7/site-packages/mistune-0.8.4-py2.7.egg-info: provides: |- python2.7dist(mistune) = 0.8.4 @@ -489,7 +489,7 @@ python(abi) = 3.7 (python3.7dist(lazy-object-proxy) >= 1.4 with python3.7dist(lazy-object-proxy) < 1.5) (python3.7dist(six) >= 1.12 with python3.7dist(six) < 2) - (python3.7dist(typed-ast) < 1.5 with python3.7dist(typed-ast) >= 1.4) + (python3.7dist(typed-ast) < 1.5~ with python3.7dist(typed-ast) >= 1.4) (python3.7dist(wrapt) >= 1.11 with python3.7dist(wrapt) < 1.12) usr/lib/python3.7/site-packages/packaging-19.0.dist-info: provides: python3.7dist(packaging) = 19 @@ -554,11 +554,11 @@ python3dist(tox) = 3.14 requires: |- python(abi) = 3.9 - (python3.9dist(filelock) < 4 with python3.9dist(filelock) >= 3) + (python3.9dist(filelock) < 4~ with python3.9dist(filelock) >= 3) python3.9dist(packaging) >= 14 - (python3.9dist(pluggy) < 1 with python3.9dist(pluggy) >= 0.12) - (python3.9dist(py) < 2 with python3.9dist(py) >= 1.4.17) - (python3.9dist(six) < 2 with python3.9dist(six) >= 1) + (python3.9dist(pluggy) < 1~ with python3.9dist(pluggy) >= 0.12) + (python3.9dist(py) < 2~ with python3.9dist(py) >= 1.4.17) + (python3.9dist(six) < 2~ with python3.9dist(six) >= 1) python3.9dist(toml) >= 0.9.4 python3.9dist(virtualenv) >= 14 usr/lib/python3.9/site-packages/urllib3-1.25.7-py3.9.egg-info: @@ -611,12 +611,12 @@ python2dist(tox) = 3.14 requires: |- python(abi) = 2.7 - (python2.7dist(filelock) < 4 with python2.7dist(filelock) >= 3) - (python2.7dist(importlib-metadata) < 1 with python2.7dist(importlib-metadata) >= 0.12) + (python2.7dist(filelock) < 4~ with python2.7dist(filelock) >= 3) + (python2.7dist(importlib-metadata) < 1~ with python2.7dist(importlib-metadata) >= 0.12) python2.7dist(packaging) >= 14 - (python2.7dist(pluggy) < 1 with python2.7dist(pluggy) >= 0.12) - (python2.7dist(py) < 2 with python2.7dist(py) >= 1.4.17) - (python2.7dist(six) < 2 with python2.7dist(six) >= 1) + (python2.7dist(pluggy) < 1~ with python2.7dist(pluggy) >= 0.12) + (python2.7dist(py) < 2~ with python2.7dist(py) >= 1.4.17) + (python2.7dist(six) < 2~ with python2.7dist(six) >= 1) python2.7dist(toml) >= 0.9.4 python2.7dist(virtualenv) >= 14 usr/lib/python2.7/site-packages/urllib3-1.25.7-py2.7.egg-info: @@ -653,12 +653,12 @@ provides: python3.7dist(tox) = 3.14 requires: |- python(abi) = 3.7 - (python3.7dist(filelock) < 4 with python3.7dist(filelock) >= 3) - (python3.7dist(importlib-metadata) < 1 with python3.7dist(importlib-metadata) >= 0.12) + (python3.7dist(filelock) < 4~ with python3.7dist(filelock) >= 3) + (python3.7dist(importlib-metadata) < 1~ with python3.7dist(importlib-metadata) >= 0.12) python3.7dist(packaging) >= 14 - (python3.7dist(pluggy) < 1 with python3.7dist(pluggy) >= 0.12) - (python3.7dist(py) < 2 with python3.7dist(py) >= 1.4.17) - (python3.7dist(six) < 2 with python3.7dist(six) >= 1) + (python3.7dist(pluggy) < 1~ with python3.7dist(pluggy) >= 0.12) + (python3.7dist(py) < 2~ with python3.7dist(py) >= 1.4.17) + (python3.7dist(six) < 2~ with python3.7dist(six) >= 1) python3.7dist(toml) >= 0.9.4 python3.7dist(virtualenv) >= 14 usr/lib64/python2.7/site-packages/scipy-1.2.1.dist-info: @@ -1251,10 +1251,10 @@ (python3.9dist(foobar33) < 2.4.8 or python3.9dist(foobar33) > 2.4.8) (python3.9dist(foobar34) < 2.4.8 or python3.9dist(foobar34) > 2.4.8) (python3.9dist(foobar35) < 2.4.8.1 or python3.9dist(foobar35) > 2.4.8.1) - (python3.9dist(foobar36) < 2.4.8 or python3.9dist(foobar36) > 2.4.9) + (python3.9dist(foobar36) < 2.4.8~ or python3.9dist(foobar36) >= 2.4.9) (python3.9dist(foobar37) < 2 or python3.9dist(foobar37) > 2) (python3.9dist(foobar38) < 2 or python3.9dist(foobar38) > 2) - (python3.9dist(foobar39) < 2 or python3.9dist(foobar39) > 3) + (python3.9dist(foobar39) < 2~ or python3.9dist(foobar39) >= 3) (python3.9dist(foobar4) >= 2 with python3.9dist(foobar4) < 3) (python3.9dist(foobar40) < 2.4.8~b5 or python3.9dist(foobar40) > 2.4.8~b5) (python3.9dist(foobar41) < 2~b5 or python3.9dist(foobar41) > 2~b5) @@ -1263,21 +1263,21 @@ python3.9dist(foobar44) <= 2.4.8 python3.9dist(foobar45) <= 2.4.8 python3.9dist(foobar46) <= 2.4.8.1 - python3.9dist(foobar47) < 2.4.8 + python3.9dist(foobar47) < 2.4.8~ python3.9dist(foobar48) <= 2 python3.9dist(foobar49) <= 2 - python3.9dist(foobar50) < 2 + python3.9dist(foobar50) < 2~ python3.9dist(foobar51) <= 2.4.8~b5 python3.9dist(foobar52) <= 2~b5 python3.9dist(foobar53) <= 2.4.8^post1 python3.9dist(foobar54) <= 2^post1 - python3.9dist(foobar55) < 2.4.8 - python3.9dist(foobar56) < 2.4.8 - python3.9dist(foobar57) < 2.4.8.1 - python3.9dist(foobar58) < 2.4.8 - python3.9dist(foobar59) < 2 - python3.9dist(foobar60) < 2 - python3.9dist(foobar61) < 2 + python3.9dist(foobar55) < 2.4.8~ + python3.9dist(foobar56) < 2.4.8~ + python3.9dist(foobar57) < 2.4.8.1~ + python3.9dist(foobar58) < 2.4.8~ + python3.9dist(foobar59) < 2~ + python3.9dist(foobar60) < 2~ + python3.9dist(foobar61) < 2~ python3.9dist(foobar62) < 2.4.8~b5 python3.9dist(foobar63) < 2~b5 python3.9dist(foobar64) < 2.4.8^post1 @@ -1294,13 +1294,13 @@ python3.9dist(foobar74) >= 2~b5 python3.9dist(foobar75) >= 2.4.8^post1 python3.9dist(foobar76) >= 2^post1 - python3.9dist(foobar77) > 2.4.8 - python3.9dist(foobar78) > 2.4.8 - python3.9dist(foobar79) > 2.4.8.1 + python3.9dist(foobar77) > 2.4.8.0 + python3.9dist(foobar78) > 2.4.8.0 + python3.9dist(foobar79) > 2.4.8.1.0 (python3.9dist(foobar8) >= 2~b5 with python3.9dist(foobar8) < 2.1) python3.9dist(foobar80) >= 2.4.8 - python3.9dist(foobar81) > 2 - python3.9dist(foobar82) > 2 + python3.9dist(foobar81) > 2.0 + python3.9dist(foobar82) > 2.0 python3.9dist(foobar83) >= 2 python3.9dist(foobar84) > 2.4.8~b5 python3.9dist(foobar85) > 2~b5