From aa8dffeb8e711eb784b7e61cd68e4a8c0606186a Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Sat, 25 Jun 2022 22:54:25 -0500 Subject: [PATCH] Write %__default_python3_version value from spec --- macros.python-srpm | 2 +- python-rpm-macros.spec | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/macros.python-srpm b/macros.python-srpm index 978ad46..2daf894 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -17,7 +17,7 @@ # There are two macros: # # This always contains the major.minor version (with dots), default for %%python3_version. -%__default_python3_version 3.11 +%__default_python3_version @@__DEFAULT_PYTHON3_VERSION@@ # # The pkgname version that determines the alternative provide name (e.g. python3.9-foo), # set to the same as above, but historically hasn't included the dot. diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 23ad248..1f44ee2 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -37,17 +37,7 @@ Source403: brp-fix-pyc-reproducibility # brp scripts: GPLv2+ License: MIT and Python and GPLv2+ -# The package version MUST be always the same as %%{__default_python3_version}. -# To have only one source of truth, we load the macro and use it. -# The macro is defined in python-srpm-macros. -%{lua: -if posix.stat(rpm.expand('%{SOURCE102}')) then - rpm.load(rpm.expand('%{SOURCE102}')) -elseif posix.stat('macros.python-srpm') then - -- something is parsing the spec without _sourcedir macro properly set - rpm.load('macros.python-srpm') -end -} +%global __default_python3_version 3.11 Version: %{__default_python3_version} Release: 2%{?dist} @@ -102,6 +92,9 @@ RPM macros for building Python 3 packages. %prep %autosetup -c -T cp -a %{sources} . +# Write definition of %%__default_python3_version from specfile into +# macros.python-srpm. +%writevars -f macros.python-srpm __default_python3_version %install @@ -153,7 +146,9 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true %changelog * Sun Jun 26 2022 Maxwell G - 3.11-2 - Define %%forgesetupargs in %%pypi_source so users can call %%forgeautosetup - or %%forgesetup and not have to define extra vars or pass -n to %setup. + or %%forgesetup and not have to define extra macros or pass -n to %setup. +- Write definition of %__default_python3_version from spec instead of + loading macros.python-srpm. * Mon Jun 13 2022 Tomáš Hrnčiar - 3.11-1 - Update main Python to Python 3.11