Issue
I am trying to get python distutils to build me an RPM. This is proving to be very difficult tho!
On my mac everything works fine, but on CentOS 6.7 (my CI server) it doesn't due to the differences RPMs are built for different platforms.
On CentOS .py
files are being precompiled by rpm/brp-python-bytecompile
. This creates .pyc
and .pyo
files, that are not listed by bdist_rpm
and thus I get an error!
I have found this issue and this issue, but they are from long long time ago! So I am surprised I still see this happening! Is there any work-around? I do not want to have to create spec file, I use bdist_rpm to avoid it... Thanks.
Here is example structure of the stuff I am trying to package:
<root>/
setup.py
my-awesome-app.py
help-scripts/
extract-config.py
Here is my setup.py:
from distutils.core import setup
setup(name='my-awesome-app',
version='1.0',
author='Daniel Gruszczyk',
scripts=['my-awesome-app.py'],
data_files=[('/etc/bake',['help-scripts/extract-config.py'])],
)
Here is example output from running python setup.py bdist_rpm
(just lines leading to error):
+ /usr/lib/rpm/find-debuginfo.sh --strict-build-id /var/lib/jenkins/workspace/my-awesome-app/build/bdist.linux-x86_64/rpm/BUILD/my-awesome-app-1.0
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: my-awesome-app-1.0-1.noarch
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: /var/lib/jenkins/.pyenv/versions/2.7.5/bin/python
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/lib/jenkins/workspace/my-awesome-app/build/bdist.linux-x86_64/rpm/BUILDROOT/my-awesome-app-1.0-1.x86_64
error: Installed (but unpackaged) file(s) found:
/etc/help-scripts/extract-config.pyc
/etc/help-scripts/extract-config.pyo
I think the + /usr/lib/rpm/brp-python-bytecompile
line is the issue (given the links I included). Is there any way to get rid of this crap, as it seems to cause problems all around?
Solution
Those bugs are old, but so is CentOS6.
Bdist_rpm is very simple and once you reach its limit, you are in dead end. And I'm really afraid no one will tell you how to fix it using setup.py. More on this topic is written here: http://ziade.org/2011/03/25/bdist_rpm-is-dead-long-life-to-py2rpm/
I really recommend you to use: pyp2rpm - https://github.com/fedora-python/pyp2rpm
Answered By - msuchy Answer Checked By - Willingham (WPSolving Volunteer)