[TIP] coverage.py with Py2 and Py3
Mark Sienkiewicz
sienkiew at stsci.edu
Mon Apr 11 13:38:58 PDT 2011
Sean Robinson wrote:
> I read the virtualenv docs earlier this morning and I had decided it
> was not what I was looking for, but I'll give it a closer look. Is
> virtualenv what others are using for this type of situation?
>
I don't. When I have different versions of python, I install them in
different directories and use an alias to set PATH/PYTHONPATH to select
the python interpreter I want.
Each python environment is entirely unaware of the existence of the
other. So, for python version X, you can install coverage. Then for
python version Y, you also install coverage. The coverage script ends
up in /usr/local/pythonX/bin/coverage and starts off
#!/usr/local/pythonX/bin/python (and similarly for Y).
I also make extensive use of --home when installing python packages:
export PYTHONPATH=$HOME/py2.6/lib/python
export PATH=$HOME/py2.6/bin:$PATH
python2.6 setup.py install --home ~/py2.6
export PYTHONPATH=$HOME/py2.7/lib/python
export PATH=$HOME/py2.7/bin:$PATH
python2.7 setup.py install --home ~/py2.7
This works if you have python installed in ~/py2.7 or if you are using
it out of /usr/bin/python2.7.
Mark S.
More information about the testing-in-python
mailing list