I am developing Python applications in Ubuntu. I want to setup a Distribute/virtualenv/pip ecosystem to manage my Python packages independently of any system Python packages (which I manage in Synaptic, or rather I let the system manage them for me).
I could just install the python-setuptools, python-virtualenv and python-pip system packages and be on my merry way, but I also want to be able to get latest/specific versions of Distribute, virtualenv and pip. There are no PPAs for these, so I'll have to install them manually.
A final complication, is that I want to be able to do this for multiple versions of Python. That is, set up one ecosystem for python2.6, another for python, another for python3, or on a 64-bit system another for chrooted 32-bit Python.
I'm guessing that the process would be something like:
- Using Python X install my own copy of Distribute to a location in my home folder
- Using indie Distribute, easy_install pip
- Using indie pip, install virtualenv
- Using indie virtualenv, create virtual environment
- Activate virtual environment, install packages
- Repeat for Python Y, Z and Q
What installation/configuration options am I looking for?
Based on Walker Hale IV's answer to a similar (but distinct! ;) ) question, there are two keys to doing this:
So the workflow is:
Notes:
I've written a bash script that does the basics in Ubuntu:
Output looks something like this (with downloading switched off and deactivation switched on):
Elaborating on JF Sebastian and nealmcb's contributions, these days I do indeed use my system packaged version of virtualenvwrapper (available on Ubuntu 12.04 and later).
The key features I use (in answer to this question) are:
mkvirtualenv --python=PYTHON_EXE
creates a virtualenv using a specific Python executable (doesn't have to be a system packaged version)allvirtualenv pip install -U pip
upgrades pip in all virtualenvsThe environment variables JFS mentioned are indeed useful to fiddle with: PIP_DOWNLOAD_CACHE, VIRTUALENV_USE_DISTRIBUTE, WORKON_HOME, VIRTUALENVWRAPPER_PYTHON.
The only reason to update virtualenv itself is to get the latest version of setuptools (previously known as Distribute, previously known as setuptools). I haven't had a need to do this yet, but I suspect it would be easiest to start with a fresh virtualenv and upgrade Distribute/setuptools first, then upgrade pip, then install other libraries.
If a new version of virtualenv is strictly necessary, a modification of the bootstrap script should do.
As noted by @j.f.sebastian, virtualenvwrapper does much or all of what you're asking for.
http://virtualenvwrapper.readthedocs.org/