Skip to content
Pranay Kanwar edited this page Jul 30, 2013 · 5 revisions

Converting python packages

Simplest possible invocation:

% fpm -s python -t rpm pyramid
Trying to download pyramid (using easy_install)
Searching for pyramid
Reading http://pypi.python.org/simple/pyramid/
Reading http://docs.pylonshq.com
Reading http://docs.pylonsproject.org
Best match: pyramid 1.0
...
Created /home/jls/python-pyramid-1.0.noarch.rpm

This will download the latest 'pyramid' python module using easy_install and convert it to an rpm. It will create a package named 'python-pyramid-VERSION_ARCH.rpm' with appropriate version/arch in place.

Check the package:

% rpm -qip python-pyramid-1.0.noarch.rpm
Name        : python-pyramid               Relocations: (not relocatable)
Version     : 1.0                               Vendor: (none)
Release     : 1                             Build Date: Mon 16 May 2011 06:41:16 PM PDT
Install Date: (not installed)               Build Host: snack.home
Group       : default                       Source RPM: python-pyramid-1.0-1.src.rpm
Size        : 2766900                          License: BSD-derived (http://www.repoze.org/LICENSE.txt)
Signature   : (none)
URL         : http://docs.pylonsproject.org
Summary     : The Pyramid web application framework, a Pylons project
Description :
The Pyramid web application framework, a Pylons project

From the above, you can see that fpm automatically picked the package name, version, maintainer, homepage, and description all from the python package itself. Nothing for you to worry about :)

How about dependencies?

 % rpm -qRp python-pyramid-1.0.noarch.rpm
 python-Chameleon >= 1.2.3
 python-Mako >= 0.3.6
 python-Paste > 1.7
 python-PasteDeploy >= 0
 python-PasteScript >= 0
 python-WebOb >= 1.0
 python-repoze.lru >= 0
 python-setuptools >= 0
 python-zope.component >= 3.6.0
 python-zope.configuration >= 0
 python-zope.deprecation >= 0
 python-zope.interface >= 3.5.1
 python-venusian >= 0.5
 python-translationstring >= 0
 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
 rpmlib(CompressedFileNames) <= 3.0.4-1

What about multiple pythons?

Some systems package python with packages named 'python24' and 'python26' etc.

You can build packages like this with fpm using the --python-package-name-prefix flag:

% ruby bin/fpm -s python -t rpm --python-package-name-prefix python26 pyramid
...
Created /home/jls/projects/fpm/python26-pyramid-1.0.noarch.rpm

% rpm -qRp python26-pyramid-1.0.noarch.rpm
python26-Chameleon >= 1.2.3
python26-Mako >= 0.3.6
python26-Paste > 1.7
python26-PasteDeploy >= 0
<remainder of output trimmed... you get the idea>

You can ask for a specific version with '-v '. It will also handle dependencies. How about an older package like pysqlite 2.5.6?

% fpm -s python -t rpm --python-package-name-prefix python26 -v 2.5.6 'pysqlite'
Trying to download pysqlite (using easy_install)
Searching for pysqlite==2.5.6
Reading http://pypi.python.org/simple/pysqlite/
Reading http://pysqlite.googlecode.com/
< ... output cut ... >
Created /home/jls/projects/fpm/python26-pysqlite-2.5.6.x86_64.rpm

Convert a local python package source

Let's say you are the developer of a python package, or you already have the local package downloaded and unpacked.

Just tell fpm where the setup.py file lives:

% ls pyramid/setup.py
pyramid/setup.py

% fpm -s python -t rpm pyramid/setup.py
...
Created /tmp/python-pyramid-1.0.noarch.rpm