scripts/pythondistdeps: Handle compatible-release operator.

This commit is contained in:
Gordon Messmer 2019-11-24 15:58:29 -08:00 committed by Panu Matilainen
parent 403f75cdbb
commit ed864b8842
1 changed files with 10 additions and 1 deletions

View File

@ -102,7 +102,7 @@ for f in files:
lower.endswith('.egg-info') or \ lower.endswith('.egg-info') or \
lower.endswith('.dist-info'): lower.endswith('.dist-info'):
# This import is very slow, so only do it if needed # This import is very slow, so only do it if needed
from pkg_resources import Distribution, FileMetadata, PathMetadata, Requirement from pkg_resources import Distribution, FileMetadata, PathMetadata, Requirement, parse_version
dist_name = basename(f) dist_name = basename(f)
if isdir(f): if isdir(f):
path_item = dirname(f) path_item = dirname(f)
@ -246,6 +246,15 @@ for name in names:
for spec in py_deps[name]: for spec in py_deps[name]:
if spec[0] == '!=': if spec[0] == '!=':
spec_list.append('{n} < {v} or {n} >= {v}.0'.format(n=name, v=spec[1])) spec_list.append('{n} < {v} or {n} >= {v}.0'.format(n=name, v=spec[1]))
elif spec[0] == '~=':
# Parse the current version
next_ver = parse_version(spec[1]).base_version.split('.')
# Drop the micro version
next_ver = next_ver[0:-1]
# Increment the minor version
next_ver[-1] = str(int(next_ver[-1]) + 1)
next_ver = '.'.join(next_ver)
spec_list.append('{n} >= {v} with {n} < {vnext}'.format(n=name, v=spec[1], vnext=next_ver))
else: else:
spec_list.append('{} {} {}'.format(name, spec[0], spec[1])) spec_list.append('{} {} {}'.format(name, spec[0], spec[1]))
print('(%s)' % ' with '.join(spec_list)) print('(%s)' % ' with '.join(spec_list))