diff --git a/macros.epel-rpm-macros b/macros.epel-rpm-macros index ef2133a..ac9a756 100644 --- a/macros.epel-rpm-macros +++ b/macros.epel-rpm-macros @@ -13,6 +13,28 @@ # Use the non-underscored Python macros to refer to Python in spec, etc. %python2 %__python2 +# This macro is copied here from https://git.centos.org/rpms/python-rpm-macros/pull-request/1 +# and is needed for the overrides in macros.zzz-epel-override. +# It will be removed once it lands in RHEL. +# +# RHEL 9+ and Fedora compatibility macro +# Only use in macro backports, not intended to be used in spec files! +# In the future, the %%python3_pkgversion macro has a dot, e.g. 3.9 or 3.11 +# However, in RHEL 8 at least, it does not, e.g. 38, 39 +# This is a helpful macro that determines the proper "Python version" string with dot +# from %%python3_pkgversion without actually having Python installed. +# For values other than 3X, it should expand to %%python3_pkgversion unchanged. +# Examples of %%python3_pkgversion -> %%_python3_pkgversion_with_dot: +# 3 -> 3 +# 38 -> 3.8 +# 39 -> 3.9 +# 310 -> 3.10 +# 3.12 -> 3.12 +# 4 -> 4 +# 412 -> 412 +%_python3_pkgversion_with_dot %{lua:print((rpm.expand("%python3_pkgversion"):gsub('^3(%d)', '3.%1')))} + + # Users can use %%python only if they redefined %%__python (e.g. to %%__python3) %python() %{lua:\ __python = rpm.expand("%__python")\ diff --git a/macros.zzz-epel-override b/macros.zzz-epel-override index 3f184c3..dfb7d12 100644 --- a/macros.zzz-epel-override +++ b/macros.zzz-epel-override @@ -1,3 +1,8 @@ # This file is used _only_ to override macros which exist in RHEL. # It should be used very sparingly. +# Override %__python3 here based on %%python3_pkgversion to avoid relying on the finicky +# python3X-rpm-macros packages. +# Backported from https://src.fedoraproject.org/rpms/python-rpm-macros/c/a8b26546eb699afe0dbfcef913a2aa7085fc5afb?branch=rawhide +%__python3 /usr/bin/python%{_python3_pkgversion_with_dot} +