Don't accidentally treat "~= X.0" requirement as "~= X"
Don't canonicalize the version twice. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1977060
This commit is contained in:
		
							parent
							
								
									5470f5688e
								
							
						
					
					
						commit
						2abcad96dd
					
				| @ -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:        41%{?dist} | Release:        42%{?dist} | ||||||
| 
 | 
 | ||||||
| # Macro files | # Macro files | ||||||
| Source001:      macros.pyproject | Source001:      macros.pyproject | ||||||
| @ -104,6 +104,10 @@ export HOSTNAME="rpmbuild"  # to speedup tox in network-less mock, see rhbz#1856 | |||||||
| %license LICENSE | %license LICENSE | ||||||
| 
 | 
 | ||||||
| %changelog | %changelog | ||||||
|  | * Tue Jun 29 2021 Miro Hrončok <mhroncok@redhat.com> - 0-42 | ||||||
|  | - Don't accidentally treat "~= X.0" requirement as "~= X" | ||||||
|  | - Fixes rhzb#1977060 | ||||||
|  | 
 | ||||||
| * Mon Jun 28 2021 Miro Hrončok <mhroncok@redhat.com> - 0-41 | * Mon Jun 28 2021 Miro Hrončok <mhroncok@redhat.com> - 0-41 | ||||||
| - Don't leak %%{_pyproject_builddir} to pytest collection | - Don't leak %%{_pyproject_builddir} to pytest collection | ||||||
| - Fixes rhzb#1935212 | - Fixes rhzb#1935212 | ||||||
|  | |||||||
| @ -25,7 +25,7 @@ class EndPass(Exception): | |||||||
| 
 | 
 | ||||||
| try: | try: | ||||||
|     from packaging.requirements import Requirement, InvalidRequirement |     from packaging.requirements import Requirement, InvalidRequirement | ||||||
|     from packaging.utils import canonicalize_name, canonicalize_version |     from packaging.utils import canonicalize_name | ||||||
| except ImportError as e: | except ImportError as e: | ||||||
|     print_err('Import error:', e) |     print_err('Import error:', e) | ||||||
|     # already echoed by the %pyproject_buildrequires macro |     # already echoed by the %pyproject_buildrequires macro | ||||||
| @ -119,14 +119,13 @@ class Requirements: | |||||||
|                 requirement.specifier, |                 requirement.specifier, | ||||||
|                 key=lambda s: (s.operator, s.version), |                 key=lambda s: (s.operator, s.version), | ||||||
|             ): |             ): | ||||||
|                 version = canonicalize_version(specifier.version) |  | ||||||
|                 if not VERSION_RE.fullmatch(str(specifier.version)): |                 if not VERSION_RE.fullmatch(str(specifier.version)): | ||||||
|                     raise ValueError( |                     raise ValueError( | ||||||
|                         f'Unknown character in version: {specifier.version}. ' |                         f'Unknown character in version: {specifier.version}. ' | ||||||
|                         + '(This is probably a bug in pyproject-rpm-macros.)', |                         + '(This is probably a bug in pyproject-rpm-macros.)', | ||||||
|                     ) |                     ) | ||||||
|                 together.append(convert(python3dist(name, python3_pkgversion=self.python3_pkgversion), |                 together.append(convert(python3dist(name, python3_pkgversion=self.python3_pkgversion), | ||||||
|                                         specifier.operator, version)) |                                         specifier.operator, specifier.version)) | ||||||
|             if len(together) == 0: |             if len(together) == 0: | ||||||
|                 print(python3dist(name, |                 print(python3dist(name, | ||||||
|                                   python3_pkgversion=self.python3_pkgversion)) |                                   python3_pkgversion=self.python3_pkgversion)) | ||||||
|  | |||||||
| @ -81,10 +81,13 @@ Build system dependencies in pyproject.toml with extras: | |||||||
|         "foo", |         "foo", | ||||||
|         "bar[bAz] > 5", |         "bar[bAz] > 5", | ||||||
|         "ne!=1", |         "ne!=1", | ||||||
|         "ge>=1.2", |         "ge>=1.2.0", | ||||||
|         "le <= 1.2.3", |         "le <= 1.2.3", | ||||||
|         "lt < 1.2.3.4      ", |         "lt < 1.2.3.4      ", | ||||||
|         "    gt > 1.2.3.4.5", |         "    gt > 1.2.3.4.5", | ||||||
|  |         "compatible ~= 0.4.0", | ||||||
|  |         "equal == 0.5.0", | ||||||
|  |         "arbitrary_equal === 0.6.0", | ||||||
|         "multi[Extras1,Extras2] == 6.0", |         "multi[Extras1,Extras2] == 6.0", | ||||||
|         "combo >2, <5, != 3.0.0", |         "combo >2, <5, != 3.0.0", | ||||||
|         "invalid!!ignored", |         "invalid!!ignored", | ||||||
| @ -100,6 +103,9 @@ Build system dependencies in pyproject.toml with extras: | |||||||
|     python3dist(le) <= 1.2.3 |     python3dist(le) <= 1.2.3 | ||||||
|     python3dist(lt) < 1.2.3.4 |     python3dist(lt) < 1.2.3.4 | ||||||
|     python3dist(gt) > 1.2.3.4.5 |     python3dist(gt) > 1.2.3.4.5 | ||||||
|  |     (python3dist(compatible) >= 0.4 with python3dist(compatible) < 0.5) | ||||||
|  |     python3dist(equal) = 0.5 | ||||||
|  |     python3dist(arbitrary-equal) = 0.6 | ||||||
|     python3dist(multi) = 6 |     python3dist(multi) = 6 | ||||||
|     python3dist(multi[extras1]) = 6 |     python3dist(multi[extras1]) = 6 | ||||||
|     python3dist(multi[extras2]) = 6 |     python3dist(multi[extras2]) = 6 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user