From 10e0e5309d691e16d2e86d329827f47993879bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 16 Mar 2023 19:43:17 +0100 Subject: [PATCH] Don't assume %_smp_mflags only ever contains -jX, use -j%_smp_build_ncpus directly When we added %_smp_mflags here, Petr Viktorin asked the question: https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/154#comment-124613 > I couldn't find docs for %_smp_mflags. > How much of a guarantee is there that it contains no other flags than -j? My answer was: > %_smp_mflags is documented in https://rpm-packaging-guide.github.io/ > and used in many other RPM macros in Fedora and upstream everywhere. > There is no official guarantee that it will never contain anything else, > but if it does, I assume multiple things would burn. > I am willing to take that risk. Turns out, the world did not burn, but packagers do set %_smp_mflags to -lX, which does not work with compileall. Fixes https://bugzilla.redhat.com/2179149 --- macros.pybytecompile | 6 +++--- macros.python-srpm | 2 +- python-rpm-macros.spec | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/macros.pybytecompile b/macros.pybytecompile index e5e5a47..e81ddae 100644 --- a/macros.pybytecompile +++ b/macros.pybytecompile @@ -35,18 +35,18 @@ py2_byte_compile () {\ py34_byte_compile () {\ python_binary="%{__env_unset_source_date_epoch_if_not_clamp_mtime} PYTHONHASHSEED=0 %1"\ bytecode_compilation_path="%2"\ - PYTHONPATH="%{_rpmconfigdir}/redhat" $python_binary -s -B -m compileall2 %{?_smp_mflags} -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes $bytecode_compilation_path \ + PYTHONPATH="%{_rpmconfigdir}/redhat" $python_binary -s -B -m compileall2 %{?_smp_build_ncpus:-j%{_smp_build_ncpus}} -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes $bytecode_compilation_path \ }\ py37_byte_compile () {\ python_binary="%{__env_unset_source_date_epoch_if_not_clamp_mtime} PYTHONHASHSEED=0 %1"\ bytecode_compilation_path="%2"\ - PYTHONPATH="%{_rpmconfigdir}/redhat" $python_binary -s -B -m compileall2 %{?_smp_mflags} -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes --invalidation-mode=timestamp $bytecode_compilation_path \ + PYTHONPATH="%{_rpmconfigdir}/redhat" $python_binary -s -B -m compileall2 %{?_smp_build_ncpus:-j%{_smp_build_ncpus}} -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes --invalidation-mode=timestamp $bytecode_compilation_path \ }\ \ py39_byte_compile () {\ python_binary="%{__env_unset_source_date_epoch_if_not_clamp_mtime} PYTHONHASHSEED=0 %1"\ bytecode_compilation_path="%2"\ - $python_binary -s -B -m compileall %{?_smp_mflags} -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes --invalidation-mode=timestamp $bytecode_compilation_path \ + $python_binary -s -B -m compileall %{?_smp_build_ncpus:-j%{_smp_build_ncpus}} -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes --invalidation-mode=timestamp $bytecode_compilation_path \ }\ \ # Path to intepreter should not contain any arguments \ diff --git a/macros.python-srpm b/macros.python-srpm index 5e57102..37cf09a 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -78,7 +78,7 @@ %__env_unset_source_date_epoch_if_not_clamp_mtime %[0%{?clamp_mtime_to_source_date_epoch} == 0 ? "env -u SOURCE_DATE_EPOCH" : "env"] ## The individual BRP scripts -%__brp_python_bytecompile %{__env_unset_source_date_epoch_if_not_clamp_mtime} %{_rpmconfigdir}/redhat/brp-python-bytecompile "" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}" "%{?_smp_mflags}" +%__brp_python_bytecompile %{__env_unset_source_date_epoch_if_not_clamp_mtime} %{_rpmconfigdir}/redhat/brp-python-bytecompile "" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}" "%{?_smp_build_ncpus:-j%{_smp_build_ncpus}}" %__brp_fix_pyc_reproducibility %{_rpmconfigdir}/redhat/brp-fix-pyc-reproducibility %__brp_python_hardlink %{_rpmconfigdir}/redhat/brp-python-hardlink diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index abf5ba1..b53f7df 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -53,7 +53,7 @@ elseif posix.stat('macros.python-srpm') then end } Version: %{__default_python3_version} -Release: 9%{?dist} +Release: 10%{?dist} BuildArch: noarch @@ -163,6 +163,10 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true %changelog +* Thu Mar 16 2023 Miro Hrončok - 3.11-10 +- Don't assume %%_smp_mflags only ever contains -jX, use -j%%_smp_build_ncpus directly +- Fixes: rhbz#2179149 + * Fri Jan 20 2023 Miro Hrončok - 3.11-9 - Memoize values of macros that execute python to get their value - Fixes: rhbz#2155505