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).
This commit is contained in:
Lumir Balhar 2020-07-21 12:59:36 +02:00
parent 06ee391993
commit 638f809f4c
3 changed files with 10 additions and 2 deletions

View File

@ -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\
}

View File

@ -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 <lbalhar@redhat.com> - 3.9-7
- Make %%py3_dist respect %%python3_pkgversion
* Thu Jul 16 2020 Miro Hrončok <mhroncok@redhat.com> - 3.9-6
- Make the unversioned %%__python macro error
- https://fedoraproject.org/wiki/Changes/PythonMacroError

View File

@ -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') == []