How to distribute Python/Django App via RPM

Nick Presta picture Nick Presta · Jul 12, 2010 · Viewed 7.1k times · Source

I've read over this question and I think that is a great start, but I'm looking for more insight.

I have written an application using Python 2.6 and Django 1.2.1. I would like to deploy this application on a system that does not have Python 2.6 or Django installed. The system itself doesn't have many things installed - sqlite3, pysqlite2, gcc, etc. The system does have Python 2.4.3, however.

What would be the most sane way to create RPMs of Python 2.6, Django, and my application itself (a standard Django app) so that each can be installed separately to allow for upgrades of different components?

I don't know much about creating source RPMs but I suspect that is information readily available. If there are any especially good resources for creating source RPMs, I would appreciate them too.

The system is ESX 4 Update 1, if it matters.

Thanks!

UPDATE: It also never occurred to me that distributing Python eggs or even using setup.py is a viable solution to content distribution. I would be interested in hearing about that too.

Answer

Ignacio Vazquez-Abrams picture Ignacio Vazquez-Abrams · Jul 14, 2010

On top of all the normal issues encountered when packaging Python code, Django projects have a few other issues that need to be handled:

  • Playing nice with system paths
  • Playing nice with system facilities
  • Handling translations
  • Randomizing the secret key

I had to solve these issues for packaging Transifex, and I recommend you investigate the various bits that have put in place in order to make it work:

  • Install under /usr/share/<projectname>
  • Use execfile() to load settings from /etc/<projectname>
  • The huge translation-handling runaround
  • Replacement of the secret key in the post-install script
  • All the other bloody changes and fudges that were required