]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph.spec.in: package .pyc files on el7 32608/head
authorKefu Chai <kchai@redhat.com>
Sun, 12 Jan 2020 09:59:11 +0000 (17:59 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 13 Jan 2020 03:09:37 +0000 (11:09 +0800)
* 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 <kchai@redhat.com>
ceph.spec.in

index 4352746406e2fd47a5b7673c7bf82a5dd7307e6b..b4792e73134b0c749eba96a3d2c4f003c08f69c6 100644 (file)
@@ -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