[Distutils] repeatable and updatable virtualenv
Carl Meyer
carl at oddbird.net
Tue Mar 16 14:00:22 CET 2010
Chris Withers wrote:
> How can I set up a virtualenv in such a way that I can version control
> the packages and their versions that are installed in it?
You'd use pip together with virtualenv (which is easy because every
virtualenv nowadays comes with pip pre-installed), and you'd
version-control a requirements file containing package names and versions.
> The answer would appear to a custom bootstrap script, but how would I
> think update an existing virtualenv when I added or removed packages or
> changed the version of a specific package?
If all the package names in your requirements.txt are version-pinned,
then "$VENV/bin/pip install -r requirements.txt" will ensure that you
have those versions of all those packages installed. The only thing it
won't do for you is remove packages that are no longer in
requirements.txt; you'd need to do that yourself with "pip uninstall
packagename" - not that having extra packages installed matters, generally.
Alternatively, if you want to be paranoid and you don't mind things
being a little slower (though not much if you have a local
PIP_DOWNLOAD_CACHE), you just create a new virtualenv each time you
deploy. Virtualenvs are disposable, only the requirements.txt matters.
Carl
More information about the Distutils-SIG
mailing list