I am trying to create a python3
package using cpack
(cmake). For some reason it is failing with a cryptic message:
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
error: Bad exit status from /var/tmp/rpm-tmp.rt2mTp (%install)
Bad exit status from /var/tmp/rpm-tmp.rt2mTp (%install)
***
CPackRPM:Debug: - /mnt/source/bin2/_CPack_Packages/Linux/RPM/rpmbuildsource-python.out
CPackRPM:Debug: *** Building target platforms: x86_64
Building for target x86_64
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.mxEjdh
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.rt2mTp
Compiling /mnt/source/bin/_CPack_Packages/Linux/RPM/project-0.0.8-Linux/python/usr/lib/python3/dist-packages/project/__init__.py ...
File "/usr/lib/python3/dist-packages/project/__init__.py", line 27
raise ValueError(f"Not a {obj.__class__.__name__} reference")
^
SyntaxError: invalid syntax
Is there a way to skip brp-python-bytecompile
step, or else is there a way to instruct cpack
that the python package only target python3
.
For reference:
# head -1 source/python/__init__.py
#!/usr/bin/env python3
There are two solutions:
/bin
hack__python
For solution #1, you simply need to use a bin
subfolder. Any python bytecompilation which happen in a sub-directory of /bin
will not be done:
For solution #2, you simply need to follow:
For cmake the syntax is:
set(CPACK_RPM_SPEC_MORE_DEFINE "%define __python python3")
See also an alternate solution: