6

Creating RPMs from python packages – James Adam

 2 years ago
source link: https://jamesadam.me/2015/07/01/creating-rpms-from-python-packages/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Creating RPMs from python packages

While I can use pip to install additional python packages on my development box, sometimes I need to deploy an application into an environment where this isn’t possible.  The best solution if the target box is an RPM-based linux distro is to install any necessary python dependencies as RPMs.  However, not all python packages are available as rpms.

To build them yourself, you’ll need a package called py2pack.  Install it thusly:

pip install py2pack

Let’s say you need to RPM-ify the fastkml package.  On CentOS/Fedora/RHEL, do the following:

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} # If you don't already have this

cd ~/rpmbuild/SOURCES
py2pack fetch fastkml 0.9  # Version number is optional

This will download the fastkml tarball into ~rpmbuild/SOURCES.  Next, you’ll need to create the RPM spec file.  Py2pack has a few templates, we’ll use the ‘Fedora’ one:

cd ~/rpmbuild/SPECS
py2pack generate fastkml 0.9 -t fedora.spec -f python-fastkml.spec

This will generate a spec file, which you may then feed into rpmbuild:

rpmbuild -bb python-fastkml.spec #Use -bs to build a source rpm

This hopefully should work, and will dump an rpm file into the ~/rpmbuild/RPMS directory.  Note: This isn’t perfect, I’ve already encountered a few python packages for which this procedure doesn’t work cleanly.

Loading...

Posted byjcadamJuly 1, 2015September 11, 2020Posted inDevelopmentTags:python


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK