Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing rpm module for (non-system) Python

Tags:

python

rpm

I need to support some software that is using an old Python version (2.4). So I have downloaded and compiled Python 2.4 and installed it in a virtualenv. So far, all OK and normal procedure.

But the software is trying to import an rpm module. And I cannot find a source for that module (it is not part of the standard Python library, afaict).

Typically, once the virtualenv is enabled (source env/bin/activate) I can install required software using easy_install. But easy_install rpm is failing to find anything. There is a pyrpm module, but it is not the same thing (it installs a module called "pyrpm"). And google searches are useless, as they all link to articles on how to build rpms...

If I were using the system python (on Ubuntu) I could install the python-rpm package. But that is for Python 2.7. How do I install the equivalent for Python 2.4?

[My impression is that the rpm libraries, used by many Linux systems, include a Python library, which is packaged as python-dev by the distro. But I can't see how to access that for an arbitrary python version.]

I AM NOT LOOKING FOR AN RPM THAT CONTAINS PYTHON 2.4. I AM LOOKING FOR A MODULE NAMED rpm THAT IS USED BY SOFTWARE WRITTEN FOR PYTHON 2.4.

like image 826
andrew cooke Avatar asked Mar 14 '13 14:03

andrew cooke


3 Answers

It's right there, in the python-rpm RPM package:

http://rpmfind.net/linux/rpm2html/search.php?query=python-rpm

You will probably want to download the package contents, extract them, and then use

python setup.py install 

From your active environment.

Of course, as it's pre compiled, you might have trouble getting the C extension to run.

I'm not familiar enough with RPM's to know whether you can get the source from there.


No guarantees the package will work with your python version though.

like image 132
Thomas Orozco Avatar answered Oct 16 '22 13:10

Thomas Orozco


there's no simple way to do this; the python library is part of the system rpm package and interfaces to C code, so is closely tied to the rpm package installed on your machine.

instead, it's much simpler to install an old OS in a VM (eg CentOS 5) that uses Python 2.4. then everything is consistent and works.

like image 37
andrew cooke Avatar answered Oct 16 '22 11:10

andrew cooke


the sources for the rpm module can be found here: http://www.rpm.org/wiki/Download

After you download the wanted version read and follow the INSTALL instructions in order to compile it on your target OS. Afterwards make sure you add the correct path to the 'site-packages' folder the installation chose into your PYTHONPATH environment variable.

To test start your python interpreter and run 'import rpm'

HTH,

Ran

like image 32
Ran Mozes Avatar answered Oct 16 '22 12:10

Ran Mozes