[TriZPUG] managing python versions as well as package versions, or "up-to-speed for the ecosystem"
Jim Allman
jim at ibang.com
Fri Aug 5 05:24:21 CEST 2011
On Aug 4, 2011, at 10:39 PM, Tom Roche wrote:
>> I just make multiple virtualenvs and activate the one I want to work
>> with at any given time. And I compile multiple Pythons, usually in
>> /opt,
>
> That I understand, but ...
>
>> to make those virtualenvs with whatever Python version I need.
>
> ... this I don't. How do you bind a given virtualenv to a given python version?
> (Or python-like thing: I've got a project I want to bind to pypy, since that way it runs in time/6.)
When you create a new virtualenv, you can specify which Python interpreter will be used in this environment. For example, to create a new virtualenv using a custom build of Python 2.4, you might do this:
$ virtualenv --python=/opt/Python-2.4/bin/python --no-site-packages ~/py24env
Note also the --no-site-packages option, which makes sure that you don't inherit any of this python's existing modules (from its site-packages directory). More examples here, showing how to confirm different versions of Python in each env:
http://www.logilab.org/blogentry/22498#work-with-different-versions-of-python
The docs are kinda sparse, but you can see the basics by simply typing this on the command line (after installing virtualenv, of course):
$ virtualenv
Once you find an option that looks interesting, it's easy to google for others' recipes and experiences with virtualenv.
Oh, and here's some good news on support for PyPy in recent versions of virtualenv:
http://www.virtualenv.org/en/latest/index.html#pypy-support
Hope this helps!
=jimA=
More information about the TriZPUG
mailing list