Automatic Provides and Requires for Python modules

Aurelien Bompard gauret at
Sun Mar 21 10:25:18 UTC 2010

Hi people,

At the top of our Python packaging page 
(, there's a note which 
reads 'In theory /usr/lib/rpm/ would also automatically 
generate "Provides" lines'

This is also true for python modules : distutils and setuptools have a way 
to specify provides and requires, but those are not reflected in the RPM.
It means that they must be entered and maintained by hand in the spec file. 
In my opinion, this is not optimal.

The perl modules have an interesting way of reflecting their dependencies in 
the rpm: they add a dependency on "perl(Module::Name)". I believe the same 
system can be applicable to python modules.

Currently, there are two main packaging systems in python : distutils and 
setuptools. Distutils declares the dependencies in an egg-info file, which 
is RFC-822-formatted. Setuptools turns this file into a PKG-INFO file in a 
subdirectory, and adds a requires.txt files with additional dependencies, in 
a different format.

The script should be able to extract requires from these 
files. To match the dependencies, should create virtual 
provides like "python(ModuleName) = version".

The good news is : I've written it already ;-)
It's based on the script from Git master (which changed a 
little bit due to python3, see bug 532118). Also, the script does not try to 
be too smart with versionned dependencies, because the format is a little 
bit different in python and in rpm. For those complicated cases, handwritten 
requirements can still be added to the spec file. The script only covers the 
usual cases.

For reference, the dependency format in distutils is described here:
The dependency format in setuptools is described here:

A patch would not make much sense due to the size of the addition, so here's 
the full script:

I've tested it with quite a few packages, but to make sure I've written a 
few unit tests (very simple, bash-based) :

I do believe it would be a valuable addition to RPM (of course, even if 
accepted shortly, I don't expect it to land in F-13 since it requires 
recompiling all the python packages).

Do you think it's a good idea ? What about the implementation ?

If it looks good to you I'll propose it to

--  ~~~~  Jabber : abompard at
"Everyone thinks of changing the world, but no one thinks of changing
himself." -- Tolstoï
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : 

More information about the python-devel mailing list