What is the correct location for a maintained virtualenv service?

Essentially the location of the virtualenv is irrelevant. You can place it wherever you want. You just have to run source some_venv/bin/activate and then you're set to go.

The traditional location is ~/.virtualenvs.

I use a different setup where I have a ~/projects folder which contains the different virtualenvs and contains the python code for different projects. This is nice and easy because you have everything together. For some it might look a bit cluttered, because you get a bin, local, and more folders in your venv.

I manage these using virtualenvwrapper which is in the repos. I did not get the chance to test pew, yet.

If virtualenvwrapper and virtualenv are set up correctly, the workflow is:

mkvirtualenv some_venv
workon some_venv
cdvirtualenv
deactivate

For Django applications, Adam Bard recommends locating your virtualenv at /opt/apps/<appname>-env and your application proper at /opt/apps/<appname>-env/site. (Many thanks to don.joey for the excellent link.)

Slightly unrelated, I also found Hynek Schlawack's Python Deployment Anti-Patterns and Python Application Deployment with Native Packages to be useful reads.

Based on this, my own review of the Filesystem Hierarchy Standard and an inspection of the /opt folder on my desktop machine, I went with:

  • /opt/virtualenv/<env_name> for the virtual environment
  • /opt/<vendor_name>/<app_name> for the server application folder

This allows me to create multiple independent virtualenvs and application folders for different applications, versions, etc as I see fit.