From 2abcad96dd4c31e496e4505c6990c46112e0e54a Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jun 29 2021 10:43:13 +0000 Subject: 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 --- diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 5f2239b..4a3a68e 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -6,7 +6,7 @@ License: MIT # Keep the version at zero and increment only release Version: 0 -Release: 41%{?dist} +Release: 42%{?dist} # Macro files Source001: macros.pyproject @@ -104,6 +104,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %license LICENSE %changelog +* Tue Jun 29 2021 Miro Hrončok - 0-42 +- Don't accidentally treat "~= X.0" requirement as "~= X" +- Fixes rhzb#1977060 + * Mon Jun 28 2021 Miro Hrončok - 0-41 - Don't leak %%{_pyproject_builddir} to pytest collection - Fixes rhzb#1935212 diff --git a/pyproject_buildrequires.py b/pyproject_buildrequires.py index cbbef0b..f5b6330 100644 --- a/pyproject_buildrequires.py +++ b/pyproject_buildrequires.py @@ -25,7 +25,7 @@ class EndPass(Exception): try: from packaging.requirements import Requirement, InvalidRequirement - from packaging.utils import canonicalize_name, canonicalize_version + from packaging.utils import canonicalize_name except ImportError as e: print_err('Import error:', e) # already echoed by the %pyproject_buildrequires macro @@ -119,14 +119,13 @@ class Requirements: requirement.specifier, key=lambda s: (s.operator, s.version), ): - version = canonicalize_version(specifier.version) if not VERSION_RE.fullmatch(str(specifier.version)): raise ValueError( f'Unknown character in version: {specifier.version}. ' + '(This is probably a bug in pyproject-rpm-macros.)', ) together.append(convert(python3dist(name, python3_pkgversion=self.python3_pkgversion), - specifier.operator, version)) + specifier.operator, specifier.version)) if len(together) == 0: print(python3dist(name, python3_pkgversion=self.python3_pkgversion)) diff --git a/pyproject_buildrequires_testcases.yaml b/pyproject_buildrequires_testcases.yaml index 5dca147..c762240 100644 --- a/pyproject_buildrequires_testcases.yaml +++ b/pyproject_buildrequires_testcases.yaml @@ -81,10 +81,13 @@ Build system dependencies in pyproject.toml with extras: "foo", "bar[bAz] > 5", "ne!=1", - "ge>=1.2", + "ge>=1.2.0", "le <= 1.2.3", "lt < 1.2.3.4 ", " gt > 1.2.3.4.5", + "compatible ~= 0.4.0", + "equal == 0.5.0", + "arbitrary_equal === 0.6.0", "multi[Extras1,Extras2] == 6.0", "combo >2, <5, != 3.0.0", "invalid!!ignored", @@ -100,6 +103,9 @@ Build system dependencies in pyproject.toml with extras: python3dist(le) <= 1.2.3 python3dist(lt) < 1.2.3.4 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[extras1]) = 6 python3dist(multi[extras2]) = 6