Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying Django with virtualenv inside a distribution package?

I have to deploy a Django application onto a SuSE Linux Enterprise 11 system. Corporate rules say I need to deploy using RPMs only. While I can use ./setup.py bdist_rpm for each dependency, it's not really sane, since RPM doesn't record all of the dependencies yet. Therefore I'd have no real advantage in using RPMs and managing dependencies manually is somewhat cumbersome and I would like to avoid it.

Now I had the following idea: While building a package, I could create a virtualenv, install all my dependencies via pip there and then package it up with the rest of the code into one solid RPM.

How sensible is this approach?

like image 230
Nikolai Prokoschenko Avatar asked Nov 03 '10 10:11

Nikolai Prokoschenko


1 Answers

I've been using this approach for about a year now and it has worked out pretty well.

One gotcha is that you'll want to check out the bang lines in any python scripts written to the virtualenv's bin directory. These will end up being full path names used in your build environment, which probably won't be the same directory where you end up installing the virtualenv. So you may need to add some sed calls in your RPM's postinstall to adjust the paths.

like image 70
pwan Avatar answered Nov 11 '22 22:11

pwan