From 567a94e63d837476dcf64dc547a17ce96d61206e Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 12 Jan 2020 17:59:11 +0800 Subject: [PATCH] ceph.spec.in: package .pyc files on el7 * package .pyc files on el7 per https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_byte_compiling it's required to package .pyc files * use python3 to bytecompile .py files on el7 per https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation#Status_quo, `brp-python-bytecompile` script bytecompile .py files automatically, the .py files under interpreter-specific directories, such as `/usr/lib/python3.6/`, are compiled using the appropriate compiler. but the mgr modules are located under `/usr/share/ceph/mgr/`. they are compiled using `${__python}`, which is still python2 in RHEL/CentOS 7. since we've dropped the support of python2 in octopus. we should either stop bytecompiling the .py source files or start using python3 to compile them. otherwise python2 will fail to compile source files using python3 specific syntax like: ``` Compiling /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos7/DIST/centos7/MACHINE_SIZE/huge/release/15.0.0-9242-g400d98b/rpm/el7/BUILDROOT/ceph-15.0.0-9242.g400d98b.el7.x86_64/usr/share/ceph/mgr/telemetry/module.py ... File "/usr/share/ceph/mgr/telemetry/module.py", line 387 anon_devid = f"{devid.rsplit('_', 1)[0]}_{uuid.uuid1()}" ^ SyntaxError: invalid syntax error: Bad exit status from /var/tmp/rpm-tmp.4oRsox (%install) ``` Signed-off-by: Kefu Chai --- ceph.spec.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ceph.spec.in b/ceph.spec.in index 4352746406e2f..b4792e73134b0 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -84,7 +84,9 @@ %{!?python3_pkgversion: %global python3_pkgversion 3} %{!?python3_version_nodots: %global python3_version_nodots 3} %{!?python3_version: %global python3_version 3} - +%if 0%{?rhel} == 7 +%define __python %{__python3} +%endif # unify libexec for all targets %global _libexecdir %{_exec_prefix}/lib @@ -1567,6 +1569,9 @@ fi %{_datadir}/ceph/mgr/test_orchestrator %{_datadir}/ceph/mgr/volumes %{_datadir}/ceph/mgr/zabbix +%if 0%{?rhel} == 7 +%{_datadir}/ceph/mgr/__pycache__ +%endif %{_unitdir}/ceph-mgr@.service %{_unitdir}/ceph-mgr.target %attr(750,ceph,ceph) %dir %{_localstatedir}/lib/ceph/mgr -- 2.39.5