From 1471429b4dec01edea9507bce2e3d54c1bbd1f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= Date: Thu, 23 Aug 2018 17:33:55 +0200 Subject: [PATCH] 2.0.0-4 - Sanitize/generalize approach to Python byte-compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...so that also out-of-Python-path *.py files (%%{_datadir}/pacemaker/tests/cts/CTSlab.py in particular) get the expected treatment now Signed-off-by: Jan Pokorný --- pacemaker.spec | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/pacemaker.spec b/pacemaker.spec index 8932971..04181ad 100644 --- a/pacemaker.spec +++ b/pacemaker.spec @@ -14,7 +14,7 @@ ## can be incremented to build packages reliably considered "newer" ## than previously built packages with the same pcmkversion) %global pcmkversion 2.0.0 -%global specversion 3 +%global specversion 4 ## Upstream commit (or git tag, such as "Pacemaker-" plus the ## {pcmkversion} macro for an official release) to use for this package @@ -55,11 +55,20 @@ ## overridable with "rpmbuild --define 'pcmk_gnutls_priorities PRIORITY-SPEC'" %define gnutls_priorities %{?pcmk_gnutls_priorities}%{!?pcmk_gnutls_priorities:@SYSTEM} -## Turn off auto-compilation of Python files outside site-packages directory, -## so that the -libs-devel package is multilib-compliant (no *.py[co] files) -## (py_auto_byte_compile macro: https://bugzilla.redhat.com/574437) -## XXX keep an eye on https://pagure.io/packaging-committee/issue/755 -%undefine py_auto_byte_compile +# Python-related definitions + +## Turn off auto-compilation of Python files outside Python specific paths, +## so there's no risk that unexpected "__python" macro gets picked to do the +## RPM-native byte-compiling there (only "{_datadir}/pacemaker/tests" affected) +## -- distro-dependent tricks or automake's fallback to be applied there +%if %{defined _python_bytecompile_extra} +%global _python_bytecompile_extra 0 +%else +### the statement effectively means no RPM-native byte-compiling will occur at +### all, so distro-dependent tricks for Python-specific packages to be applied +%global __os_install_post %(echo '%{__os_install_post}' | { + sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g'; }) +%endif ## Values that differ by Python major version %global python_path /usr/bin/python%{?python3_pkgversion}%{!?python3_pkgversion:3} @@ -378,7 +387,13 @@ make %{_smp_mflags} V=1 all [ -f .CHECKED ] && rm -f -- .CHECKED %install -make DESTDIR=%{buildroot} docdir=%{pcmk_docdir} V=1 install +# skip automake-native Python byte-compilation, since RPM-native one (possibly +# distro-confined to Python-specific directories, which is currently the only +# relevant place, anyway) assures proper intrinsic alignment with wider system +# (such as with py_byte_compile macro, which is concurrent Fedora/EL specific) +make install \ + DESTDIR=%{buildroot} V=1 docdir=%{pcmk_docdir} \ + %{?_python_bytecompile_extra:%{?py_byte_compile:am__py_compile=true}} mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig install -m 644 daemons/pacemakerd/pacemaker.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/pacemaker @@ -386,7 +401,7 @@ install -m 644 tools/crm_mon.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig mkdir -p %{buildroot}%{_datadir}/pacemaker/nagios/plugins-metadata for file in $(find %{nagios_name}-%{nagios_hash}/metadata -type f); do - install -m 644 $file %{buildroot}%{_datadir}/pacemaker/nagios/plugins-metadata + install -m 644 $file %{buildroot}%{_datadir}/pacemaker/nagios/plugins-metadata done @@ -414,6 +429,14 @@ rm -f %{buildroot}/%{_sbindir}/ipmiservicelogd rm -f %{buildroot}/%{_initrddir}/pacemaker rm -f %{buildroot}/%{_initrddir}/pacemaker_remote +# Byte-compile Python sources where suitable and the distro procedures known +%if %{defined py_byte_compile} && %{defined python_path} +%{py_byte_compile %{python_path} %{buildroot}%{_datadir}/pacemaker/tests} +%if !%{defined _python_bytecompile_extra} +%{py_byte_compile %{python_path} %{buildroot}%{py_site}/cts} +%endif +%endif + %if %{with coverage} GCOV_BASE=%{buildroot}/%{_var}/lib/pacemaker/gcov mkdir -p $GCOV_BASE @@ -676,6 +699,11 @@ exit 0 %license %{nagios_name}-%{nagios_hash}/COPYING %changelog +* Thu Aug 23 2018 Jan Pokorný - 2.0.0-4 +- Sanitize/generalize approach to Python byte-compilation, so that also + out-of-Python-path *.py files (%%{_datadir}/pacemaker/tests/cts/CTSlab.py + in particular) get the expected treatment now + * Wed Aug 15 2018 Jan Pokorný - 2.0.0-3 - Fix Python 3.7 incompatibility (otherwise missed in bytecompilation phase, see rhbz#1616219)