Handle legacy version specifiers that would previously raise exceptions.
This commit is contained in:
parent
55905e4681
commit
ec5fc7a5cd
@ -6,7 +6,7 @@ License: MIT
|
|||||||
|
|
||||||
# Keep the version at zero and increment only release
|
# Keep the version at zero and increment only release
|
||||||
Version: 0
|
Version: 0
|
||||||
Release: 51%{?dist}
|
Release: 52%{?dist}
|
||||||
|
|
||||||
# Macro files
|
# Macro files
|
||||||
Source001: macros.pyproject
|
Source001: macros.pyproject
|
||||||
@ -116,6 +116,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
|||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Dec 19 2021 Gordon Messmer <gordon.messmer@gmail.com> - 0-52
|
||||||
|
- Handle legacy version specifiers that would previously raise exceptions.
|
||||||
|
|
||||||
* Wed Dec 08 2021 Miro Hrončok <mhroncok@redhat.com> - 0-51
|
* Wed Dec 08 2021 Miro Hrončok <mhroncok@redhat.com> - 0-51
|
||||||
- Define provisional %%pyproject_build_lib
|
- Define provisional %%pyproject_build_lib
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ class RpmVersion():
|
|||||||
# in public releases
|
# in public releases
|
||||||
# https://www.python.org/dev/peps/pep-0440/#local-version-identifiers
|
# https://www.python.org/dev/peps/pep-0440/#local-version-identifiers
|
||||||
|
|
||||||
|
def is_legacy(self):
|
||||||
|
return isinstance(self.version, str)
|
||||||
|
|
||||||
def increment(self):
|
def increment(self):
|
||||||
self.version[-1] += 1
|
self.version[-1] += 1
|
||||||
self.pre = None
|
self.pre = None
|
||||||
@ -48,7 +51,7 @@ class RpmVersion():
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if isinstance(self.version, str):
|
if self.is_legacy():
|
||||||
return self.version
|
return self.version
|
||||||
if self.epoch:
|
if self.epoch:
|
||||||
rpm_epoch = str(self.epoch) + ':'
|
rpm_epoch = str(self.epoch) + ':'
|
||||||
@ -71,6 +74,9 @@ def convert_compatible(name, operator, version_id):
|
|||||||
if version_id.endswith('.*'):
|
if version_id.endswith('.*'):
|
||||||
return 'Invalid version'
|
return 'Invalid version'
|
||||||
version = RpmVersion(version_id)
|
version = RpmVersion(version_id)
|
||||||
|
if version.is_legacy():
|
||||||
|
# LegacyVersions are not supported in this context
|
||||||
|
return 'Invalid version'
|
||||||
if len(version.version) == 1:
|
if len(version.version) == 1:
|
||||||
return 'Invalid version'
|
return 'Invalid version'
|
||||||
upper_version = RpmVersion(version_id)
|
upper_version = RpmVersion(version_id)
|
||||||
@ -96,6 +102,9 @@ def convert_not_equal(name, operator, version_id):
|
|||||||
if version_id.endswith('.*'):
|
if version_id.endswith('.*'):
|
||||||
version_id = version_id[:-2]
|
version_id = version_id[:-2]
|
||||||
version = RpmVersion(version_id)
|
version = RpmVersion(version_id)
|
||||||
|
if version.is_legacy():
|
||||||
|
# LegacyVersions are not supported in this context
|
||||||
|
return 'Invalid version'
|
||||||
version_gt = RpmVersion(version_id).increment()
|
version_gt = RpmVersion(version_id).increment()
|
||||||
version_gt_operator = '>='
|
version_gt_operator = '>='
|
||||||
# Prevent dev and pre-releases from satisfying a < requirement
|
# Prevent dev and pre-releases from satisfying a < requirement
|
||||||
@ -126,12 +135,14 @@ def convert_ordered(name, operator, version_id):
|
|||||||
operator = '<'
|
operator = '<'
|
||||||
else:
|
else:
|
||||||
version = RpmVersion(version_id)
|
version = RpmVersion(version_id)
|
||||||
# Prevent dev and pre-releases from satisfying a < requirement
|
# For backwards compatibility, fallback to previous behavior with LegacyVersions
|
||||||
if operator == '<' and not version.pre and not version.dev and not version.post:
|
if not version.is_legacy():
|
||||||
version = '{}~~'.format(version)
|
# Prevent dev and pre-releases from satisfying a < requirement
|
||||||
# Prevent post-releases from satisfying a > requirement
|
if operator == '<' and not version.pre and not version.dev and not version.post:
|
||||||
if operator == '>' and not version.pre and not version.dev and not version.post:
|
version = '{}~~'.format(version)
|
||||||
version = '{}.0'.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)
|
return '{} {} {}'.format(name, operator, version)
|
||||||
|
|
||||||
OPERATORS = {'~=': convert_compatible,
|
OPERATORS = {'~=': convert_compatible,
|
||||||
|
Loading…
Reference in New Issue
Block a user