From 638f809f4c15b8b14dfc1f6f8c3c08b0d2ba0b70 Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Jul 21 2020 11:42:58 +0000 Subject: Make %py3_dist respect %python3_pkgversion By default, %{py3_dist foo} generates python3dist(foo). This change makes it respect %python3_pkgversion so when it is redefined as X.Y, %{py3_dist foo} generates pythonX.Y(foo). --- diff --git a/macros.python-srpm b/macros.python-srpm index fa9f06a..494e3ff 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -90,6 +90,7 @@ # Needs to first put all arguments into a list, because invoking a different # macro (%py_dist_name) overwrites them %py3_dist() %{lua:\ + python3_pkgversion = rpm.expand("%python3_pkgversion");\ args = {}\ arg = 1\ while (true) do\ @@ -102,7 +103,7 @@ end\ for arg, name in ipairs(args) do\ canonical = rpm.expand("%py_dist_name " .. name);\ - print("python3dist(" .. canonical .. ") ");\ + print("python" .. python3_pkgversion .. "dist(" .. canonical .. ") ");\ end\ } diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index b0b2678..be4c08d 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3.9 -Release: 6%{?dist} +Release: 7%{?dist} Summary: The common Python RPM macros # macros and lua: MIT, compileall2.py: PSFv2 @@ -107,6 +107,9 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/ %changelog +* Tue Jul 21 2020 Lumír Balhar - 3.9-7 +- Make %%py3_dist respect %%python3_pkgversion + * Thu Jul 16 2020 Miro Hrončok - 3.9-6 - Make the unversioned %%__python macro error - https://fedoraproject.org/wiki/Changes/PythonMacroError diff --git a/tests/test_evals.py b/tests/test_evals.py index a46c6ad..fa49439 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -50,6 +50,10 @@ def test_py3_dist(): assert rpm_eval(f'%py3_dist Aha[Boom] a') == ['python3dist(aha[boom]) python3dist(a)'] +def test_py3_dist_with_python3_pkgversion_redefined(): + assert rpm_eval(f'%py3_dist Aha[Boom] a', python3_pkgversion="3.6") == ['python3.6dist(aha[boom]) python3.6dist(a)'] + + def test_python_provide_python(): assert rpm_eval('%python_provide python-foo') == []