Creating Python RPM

chrisg picture chrisg · Feb 24, 2010 · Viewed 9.2k times · Source

I have been reading about creating an RPM for Python 2.6.4. In this page: http://docs.python.org/distutils/builtdist.html it says you can create an RPM of the current Python using python setup.py bdist_rpm. The question's I have are:

  • Do you have to type this command in your Python installation directory?
  • Does this command, package all the modules you have installed into the RPM?
  • Is this the correct command to do this?
  • Are there any other suggestion's that would make this easier?

Okay I sorted this out using checkinstall.

I downloaded checkinstall from http://www.asic-linux.com.mx/~izto/checkinstall/.

I then installed the package but had to enter /usr/local/sbin/checkinstall into my PATH to make it work. I then entered the next copmmand to get my RPM directory going.

 yum install rpm-build

I then cd into the Python module and entered this command:

 checkinstall -R --nodoc --delspec=no  --exclude=/selinux python2.6 ./setup.py install

This command replaces the command checkinstall as your installing python libraries through setup.py instead of an ordinary make.

I then went through the checkinstall process. The finished RPM was placed into /usr/src/redhat/RPMS/i386/.

Note: THIS IS FOR LINUX RED HAT.

Answer

Ignacio Vazquez-Abrams picture Ignacio Vazquez-Abrams · Feb 24, 2010
  1. This command has to be typed wherever your setup.py is located.
  2. It packages everything that would show up in a bdist tarball.
  3. Err... sort of. While it works, the package it creates is not of very high quality. It's better to use sdist_rpm, then unpack the resulting SRPM and then apply your distro's Python packaging guidelines to the generated spec file.
  4. Get it to work via bdist first. That way any issues that crop up will be more manageable.