[Python-Dev] In-Python virtualisation and packaging

Vinay Sajip vinay_sajip at yahoo.co.uk
Mon Jun 13 13:47:33 CEST 2011

Back in March this year, Carl Meyer did some work to see if it was feasible
to bring virtualenv functionality into Python [1] (code at [2]).

Carl's changes were to Python code only, which was almost but not quite enough.
I built on his changes with updates to C code in getpath.c/getpathp.c, and my
code is at [3]. I've kept it synchronised with the core cpython repo, including
the recently committed packaging modules.

While there are issues to work through such as dealing with source builds (and
no doubt plenty of others), it now seems possible to create virtual
environments and install stuff into them using just the stdlib (modulo
currently needing Distribute for the packages which don't yet support
setup.cfg-based packaging, but it's all done automatically for a user). So you
can do e.g.

$ python3.3 -m virtualize /tmp/venv
$ source /tmp/venv/bin/activate.sh
$ pysetup3 install Mako

and so on. A log of early experiments, which seems reasonably promising, is at

Do people agree that it may be fitting, proper and timely to bring
virtualisation into Python, and are there any fundamental flaws anyone can see
with the approach used?

If people want to experiment with this code without cloning and building, I
created a Debian package using checkinstall, which can be installed using

sudo dpkg -i pythonv_3.3-1_i386.deb

and removed using

sudo dpkg -r pythonv

I can make this Debian package available for download, if anyone wants it.


Vinay Sajip

[1] http://mail.python.org/pipermail/distutils-sig/2011-March/017519.html
[2] https://bitbucket.org/carljm/cpythonv
[3] https://bitbucket.org/vinay.sajip/pythonv
[4] https://gist.github.com/1022601

More information about the Python-Dev mailing list