Python Setuptools and Building RPMs with Dependencies.
If you develop python modules for distribution, you likely use python setuptools. It's very useful and takes lots of the manual operations out of distributing python code and modules. I recently started going one step further and using the bdist_rpm setup.py command option to automatically build rpms for my python code and modules too. Unfortunately, I found a bug (on RHEL 6 version of setuptools at least) in that it doesn't appear the install_requires directive in setup.py is being read or used correctly.
After adding install_requires=['requests'] to the setup.py file, the rpm spec file that python setup.py bdist_rpm created did NOT include the correct Requires: line required to include the dependency in the RPM. I experimented with the argument supplied (eg python-requests/requests) and other such things, but was not able to build an RPM with the dependencies on the python-requests RPM that I wanted to include.
After some playing and research, I was finally able to get it to generate an RPM with the correct dependency on python-requests by creating and using this custom setup.cfg file:
1cat << EOF > setup.cfg 2[bdist_rpm] 3requires = python-requests >= 1.1 4no-autoreq = yes 5EOF
The other line in there (no-autoreq) tells setup.py not to analyse your code for dependencies and include those in the RPM too. I added this because by default, the generated RPM had tied a dependency to python 2.6 (RHEL 6) but I wanted an RPM generated that would run on python 2.7 (RHEL 7) too so adding this flag removes any dependency on a specific python version