summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiro HronĨok <miro@hroncok.cz>2019-06-20 11:03:40 +0200
committerPanu Matilainen <pmatilai@redhat.com>2020-03-26 11:57:58 +0200
commitc0f85d59200c33c845f2ada9cf61b021188014c0 (patch)
tree75f1449a793dad4c722eefcf20fbc24162e56143
parent1f0e8fd1317117dabf0d2e35b636dfb39e382d74 (diff)
downloadrpm-c0f85d59200c33c845f2ada9cf61b021188014c0.tar.gz
Canonicalize Python versions and properly handle != spec
Fixes https://github.com/rpm-software-management/rpm/issues/639 (cherry picked from commit 4c8b584074061c606883ce3f18c8c9024d8610f5)
-rwxr-xr-xscripts/pythondistdeps.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/scripts/pythondistdeps.py b/scripts/pythondistdeps.py
index 8d8bbfc19..3c24e9c38 100755
--- a/scripts/pythondistdeps.py
+++ b/scripts/pythondistdeps.py
@@ -145,7 +145,10 @@ for f in files:
if legacy_name not in py_deps:
py_deps[legacy_name] = []
if dist.version:
- spec = ('==', dist.version)
+ version = dist.version
+ while version.endswith('.0'):
+ version = version[:-2]
+ spec = ('==', version)
if spec not in py_deps[name]:
if not legacy:
py_deps[name].append(spec)
@@ -189,11 +192,12 @@ for f in files:
else:
name = 'python{}dist({})'.format(dist.py_version, dep.key)
for spec in dep.specs:
- if spec[0] != '!=':
- if name not in py_deps:
- py_deps[name] = []
- if spec not in py_deps[name]:
- py_deps[name].append(spec)
+ while spec[1].endswith('.0'):
+ spec = (spec[0], spec[1][:-2])
+ if name not in py_deps:
+ py_deps[name] = []
+ if spec not in py_deps[name]:
+ py_deps[name].append(spec)
if not dep.specs:
py_deps[name] = []
# Unused, for automatic sub-package generation based on 'extras' from egg/dist metadata
@@ -239,7 +243,10 @@ for name in names:
if py_deps[name]:
# Print out versioned provides, requires, recommends, conflicts
for spec in py_deps[name]:
- print('{} {} {}'.format(name, spec[0], spec[1]))
+ if spec[0] == '!=':
+ print('({n} < {v} or {n} >= {v}.0)'.format(n=name, v=spec[1]))
+ else:
+ print('{} {} {}'.format(name, spec[0], spec[1]))
else:
# Print out unversioned provides, requires, recommends, conflicts
print(name)