diff --git a/macros.python b/macros.python index 20cde47..9e2c37f 100644 --- a/macros.python +++ b/macros.python @@ -4,6 +4,9 @@ %python_sitearch %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") %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 ea38385..9172c13 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 caeef87..07eb1ed 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 57%{?dist} +Release: 59%{?dist} Summary: The unversioned Python RPM macros # macros: MIT, compileall2.py: PSFv2 @@ -80,6 +80,10 @@ install -m 644 %{SOURCE5} \ %changelog +* Thu Sep 24 2020 Miro Hrončok - 3-59 +- Add %%python3_platform_triplet and %%python3_ext_suffix +- https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names + * Mon Jun 15 2020 Miro Hrončok - 3-57 - Allow to combine %%pycached with other macros (e.g. %%exclude or %%ghost) (#1838992) diff --git a/tests/test_evals.py b/tests/test_evals.py index b585754..a65cd9d 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -1,7 +1,10 @@ import os import subprocess +import platform import sys +import pytest + X_Y = f'{sys.version_info[0]}.{sys.version_info[1]}' XY = f'{sys.version_info[0]}{sys.version_info[1]}' @@ -221,3 +224,17 @@ def test_pycached_with_exclude(): def test_pycached_fails_with_extension_glob(): lines = rpm_eval('%pycached %{python3_sitelib}/foo.py*', fails=True) assert lines[0] == 'error: %pycached can only be used with paths explicitly ending with .py' + + +# 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}m-x86_64-linux-gnu.so"