diff --git a/macros.python b/macros.python index 1ed0219..7059a8e 100644 --- a/macros.python +++ b/macros.python @@ -5,6 +5,8 @@ %python_version %(%{__python} -Esc "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))") %python_version_nodots %(%{__python} -Esc "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") %python_platform %(%{__python} -Esc "import sysconfig; print(sysconfig.get_platform())") +%python_platform_triplet %(%{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))") +%python_ext_suffix %(%{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))") %py_setup setup.py %py_shbang_opts -s diff --git a/macros.python3 b/macros.python3 index 714d9ca..9e37a8a 100644 --- a/macros.python3 +++ b/macros.python3 @@ -3,6 +3,8 @@ %python3_version %(%{__python3} -Ic "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))") %python3_version_nodots %(%{__python3} -Ic "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") %python3_platform %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())") +%python3_platform_triplet %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))") +%python3_ext_suffix %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))") %py3dir %{_builddir}/python3-%{name}-%{version}-%{release} %py3_shbang_opts -s diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 579fae1..e2c7092 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3.9 -Release: 9%{?dist} +Release: 10%{?dist} Summary: The common Python RPM macros # macros and lua: MIT, compileall2.py: PSFv2 @@ -107,6 +107,10 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/ %changelog +* Mon Sep 14 2020 Miro Hrončok - 3.9-10 +- Add %%python3_platform_triplet and %%python3_ext_suffix +- https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names + * Fri Jul 24 2020 Lumír Balhar - 3.9-9 - Adapt %%py[3]_shebang_fix to use versioned pathfixX.Y.py diff --git a/tests/test_evals.py b/tests/test_evals.py index 20af7ca..62bd39c 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -1,5 +1,6 @@ import os import subprocess +import platform import sys import textwrap @@ -398,6 +399,8 @@ unversioned_macros = pytest.mark.parametrize('macro', [ '%python_sitelib', '%python_sitearch', '%python_platform', + '%python_platform_triplet', + '%python_ext_suffix', '%py_shebang_fix', '%py_build', '%py_build_egg', @@ -419,3 +422,17 @@ def test_unversioned_python_errors(macro): def test_unversioned_python_works_when_defined(macro): macro3 = macro.replace('python', 'python3').replace('py_', 'py3_') assert rpm_eval(macro, __python='/usr/bin/python3') == rpm_eval(macro3) + + +# we could rework the test for multiple architectures, but the Fedora CI currently only runs on x86_64 +x86_64_only = pytest.mark.skipif(platform.machine() != "x86_64", reason="works on x86_64 only") + + +@x86_64_only +def test_platform_triplet(): + assert rpm_eval("%python3_platform_triplet")[0] == "x86_64-linux-gnu" + + +@x86_64_only +def test_ext_suffix(): + assert rpm_eval("%python3_ext_suffix")[0] == f".cpython-{XY}-x86_64-linux-gnu.so"