From a8c53aa651f2c14fb2be53b03f5ba5f12b368058 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Tue, 7 Jun 2022 18:43:39 -0500 Subject: [PATCH] Make %pytest and %py3_dist compatible with alt. pythons --- macros.zzz-epel-override | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/macros.zzz-epel-override b/macros.zzz-epel-override index dfb7d12..2e089ee 100644 --- a/macros.zzz-epel-override +++ b/macros.zzz-epel-override @@ -6,3 +6,31 @@ # Backported from https://src.fedoraproject.org/rpms/python-rpm-macros/c/a8b26546eb699afe0dbfcef913a2aa7085fc5afb?branch=rawhide %__python3 /usr/bin/python%{_python3_pkgversion_with_dot} +# RHEL 8's %%pytest does not work properly on non-default Python versions. +# Backported from https://src.fedoraproject.org/rpms/python-rpm-macros/c/02536540768555dde6d675935db45df81bcab7bf?branch=rawhide +%__pytest /usr/bin/pytest%(test %{python3_pkgversion} == 3 || echo -%{python3_version}) + +# RHEL 8's %%py3_dist does not work properly on non-default Python versions. +# This is copied here from https://git.centos.org/rpms/python-rpm-macros/pull-request/1 +# until that lands in RHEL. + +# Creates Python 3 dist tag(s) after converting names to canonical format +# Needs to first put all arguments into a list, because invoking a different +# macro (%py_dist_name) overwrites them +%py3_dist() %{lua:\ + python3_pkgversion_with_dot = rpm.expand("%_python3_pkgversion_with_dot")\ + args = {}\ + arg = 1\ + while (true) do\ + name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\ + if (name == nil or name == '') then\ + break\ + end\ + args[arg] = name\ + arg = arg + 1\ + end\ + for arg, name in ipairs(args) do\ + canonical = rpm.expand("%py_dist_name " .. name);\ + print("python" .. python3_pkgversion_with_dot .. "dist(" .. canonical .. ") ");\ + end\ +}