Turn a pyton app into an RPM

I needed to turn the s3cmd app, a python app which is available as a tar file, into an RPM. There are RPMs of s3cmd, but I needed an RPM of version 1.1.0-beta-3 because it worked on CentOS 7 with its python 2.7, but didn't have the can't transfer files smaller than 5MB problem that version 1.5.x has on CentOS.

Fortunately, s3cmd is written in python, and python has bdist which allows you to create binary distributions, such as RPMs. Assuming the python app can be installed via 'python setup.py install', creating an RPM should be easy. cd into the directory where the app's setup.py file is and run python setup.py bdist_rpm The first time I tried, it failed when dealing with the doc files/man pages. Since I didn't care about those, I ran 'export S3CMD_PACKAGING=yes' as suggested by the INSTALL file for s3cmd if one does not care about man pages. When I ran python setup.py bdist_rpm again it succeeded and I found the RPM (and source RPM, too!) in the dist directory. The RPM installed with no problems. (This was not surprising as running 'python setup.py install' had also run without issues.)