Re:Starting a Django Project the Right Way
by tocomment on Wednesday July 25, 2012 @07:41AM
(#4290391)
So do you use virtualenv in production? Is there a good tutorial on this for my developers?
[ Parent
| on HN ]
> So do you use virtualenv in production? Is there a good tutorial on this for my developers?
Using virtualenv in production mostly boils down to `pip -r reqs.txt -E virtual_env`(in place of pip install -r reqs.txt) and making sure virtualenv path is the first in sys.path http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
You can also execfile the activation script, but I prefer changing sys.path.
I don't think there is any 'best practice' as of yet. It ranges from just running virtualenv, and then using pip + requirements.txt on deploy, to packaging up your virtualenv in a .rpm/.deb and installing via your distro's package manager.
Re:Starting a Django Project the Right Way
by tocomment on Wednesday July 25, 2012 @09:09AM
(#4290716)
What's the benefit of using virtualenv in production? And actually what's the benefit in general?
The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.7/site-packages (or whatever your platform’s standard location is), it’s easy to end up in a situation where you unintentionally upgrade an application that shouldn’t be upgraded.
Re:Starting a Django Project the Right Way
by AUmrysh on Wednesday July 25, 2012 @12:14PM
(#4291585)
Additionally, you may run into a problem where your distribution only offers certain versions of python and its packages, when you need newer versions. On systems like CentOS, this becomes a bit more complex as you can wind up in 'dependency hell' trying to compile everything you may need for a complex python program. virtualenv and pip make this very easy to manage and set up.