From 9210ff19a239816c22d5d592cdca080d4b8ecffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 12 Nov 2024 01:14:19 +0100 Subject: [PATCH] Accept arbitrary options from %pyproject_buildrequires in pyproject-srpm-macros This way, when we add new options to the actual macro in pyproject-rpm-macros, spec files that use them are parsable with the old pyproject-srpm-macros package. Last time, when we added the -g option in 1.16.0, it took at least a week for Fedora CI to be able to parse a spec file with it, as pyproject-srpm-macros 1.16.0+ needed to actually be installed on the CI systems. Next time this happens, the new option will be parsable with older versions of pyproject-rpm-macros Note that the (-) syntax is not supported yet on RPM 4.16 in RHEL 9. I'd use an expression to keep the literal set of flags for older RPM versions: %pyproject_buildrequires(%[v"0%{?rpmversion}" >= v"4.19" ? "-" : "rRxtNwpe:g:C:"]) But macro options are not processed as macros: https://github.com/rpm-software-management/rpm/issues/3440 As a result, this is not compatible with RHEL 9 and cannot be backported to it. Unless the (-) syntax is backported: https://issues.redhat.com/browse/RHEL-67161 https://gitlab.com/redhat/centos-stream/rpms/rpm/-/merge_requests/60 (cherry picked from Fedora commit c1de18f683ce58da054e1bbe9b85cdeb14668957) Amended for RHEL 9 to require rpm-build >= 4.16.1.3-37 for the (-) syntax backport. --- macros.aaa-pyproject-srpm | 4 ++-- macros.pyproject | 1 - pyproject-rpm-macros.spec | 21 ++++++++++----------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/macros.aaa-pyproject-srpm b/macros.aaa-pyproject-srpm index 1b06ac3..b394be5 100644 --- a/macros.aaa-pyproject-srpm +++ b/macros.aaa-pyproject-srpm @@ -3,8 +3,8 @@ # When this file is installed but macros.pyproject is not # this macro will cause the package with the real macro to be installed. # When macros.pyproject is installed, it overrides this macro. -# Note: This needs to maintain the same set of options as the real macro. -%pyproject_buildrequires(rRxtNwpe:g:C:) echo 'pyproject-rpm-macros' && exit 0 +# Note: This takes arbitrary options, to ease addition of new options to the real macro. +%pyproject_buildrequires(-) echo 'pyproject-rpm-macros' && exit 0 # Declarative buildsystem, requires RPM 4.20+ to work diff --git a/macros.pyproject b/macros.pyproject index 449afe6..af6b441 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -166,7 +166,6 @@ fi ]"\ ] -# Note: Keep the options in sync with this macro from macros.aaa-pyproject-srpm %pyproject_buildrequires(rRxtNwpe:g:C:) %{expand:\\\ %_set_pytest_addopts # The default flags expect the package note file to exist diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index da44d25..105c2a5 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -14,7 +14,7 @@ License: MIT # Increment Y and reset Z when new macros or features are added # Increment Z when this is a bugfix or a cosmetic change # Dropping support for EOL Fedoras is *not* considered a breaking change -Version: 1.16.2 +Version: 1.16.3 Release: 1%{?dist} # Macro files @@ -97,8 +97,9 @@ Requires: /usr/bin/sed # It has been introduced in RPM 4.15 (4.14.90 is the alpha of 4.15). # What we need is rpmlib(DynamicBuildRequires), but that is impossible to (Build)Require. # Also, we need to avoid 4.19.90..4.19.91-7 due to rhbz#2284187 -Requires: ((rpm-build >= 4.14.90 with (rpm-build < 4.19.90 or rpm-build >= 4.19.91-8)) if rpm-build) -BuildRequires: rpm-build >= 4.14.90 +# Also, we need 4.16.1.3-37 or newer to get RHEL-67161 +Requires: ((rpm-build >= 4.16.1.3-37 with (rpm-build < 4.19.90 or rpm-build >= 4.19.91-8)) if rpm-build) +BuildRequires: rpm-build >= 4.16.1.3-37 %description These macros allow projects that follow the Python packaging specifications @@ -118,7 +119,7 @@ which only work with setup.py. %package -n pyproject-srpm-macros Summary: Minimal implementation of %%pyproject_buildrequires Requires: (pyproject-rpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} if pyproject-rpm-macros) -Requires: (rpm-build >= 4.14.90 if rpm-build) +Requires: (rpm-build >= 4.16.1.3-37 if rpm-build) %description -n pyproject-srpm-macros This package contains a minimal implementation of %%pyproject_buildrequires. @@ -152,15 +153,9 @@ install -pm 644 pyproject_construct_toxenv.py %{buildroot}%{_rpmconfigdir}/redha install -pm 644 pyproject_requirements_txt.py %{buildroot}%{_rpmconfigdir}/redhat/ install -pm 644 pyproject_wheel.py %{buildroot}%{_rpmconfigdir}/redhat/ -%check -# assert the two signatures of %%pyproject_buildrequires match exactly -signature1="$(grep '^%%pyproject_buildrequires' macros.pyproject | cut -d' ' -f1)" -signature2="$(grep '^%%pyproject_buildrequires' macros.aaa-pyproject-srpm | cut -d' ' -f1)" -test "$signature1" == "$signature2" -# but also assert we are not comparing empty strings -test "$signature1" != "" %if %{with tests} +%check export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856356 %pytest -vv --doctest-modules %{?with_pytest_xdist:-n auto} %{!?with_tox_tests:-k "not tox"} @@ -196,6 +191,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %changelog +* Tue Dec 03 2024 Miro Hrončok - 1.16.3-1 +- Accept arbitrary options from %%pyproject_buildrequires in pyproject-srpm-macros +- This will make future additions smoother + * Wed Nov 13 2024 Miro Hrončok - 1.16.2-1 - Fix one remaining test for setuptools 70+