12

I have a build box which supports python 2.4, 2.6 and 2.7. This leads to installing various versions of pips as required in their own python installations. I'm using tox to run tests through setup.py.

Whenever I run a {python2.7_installation_dir}/bin/python setup.py test, this results in a .tox directory. Inside .tox directory I run

py27/bin/pip --version pip 1.4.1 from {my_package}/.tox/py27/lib/python2.7/site-packages (python 2.7) [buildbot@BUILD-SERV-01 .tox]# python2.7 Python 2.7.6 (default, Nov 20 2013, 15:33:09) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pip >>> pip.__version__ '1.5.2' 

So the version of pip inside .tox directory is 1.4.1 where as pip installed for python interpreter that I'm using to execute the setup.py test is 1.5.2. This leads to errors when running tests as it uses pip to install the directories and some of them come from external sources and in 1.5.2 we need to set explicitly --allow-external --allow-unverified flag for one of the module which doesn't exist in 1.4.1, which results in an error each time i invoke tests through tox.

There is only one python2.7 installation and it is installed from source. But I think it was running pip 1.4.1, but now been upgraded to use 1.5.2. How tox can use the old version? Is there any .pth file or something that could have been left behind which needs clearing up?

I could drop tox and run pytests directly but I'd prefer to run them via tox.
Please let me know if you want to see the logs, I can update the question with the log.

2
  • 1
    Have you found a solution? I have the same problem. Commented Apr 6, 2014 at 6:55
  • No I gave up on tox cowardly due to lack of time to look into it! Commented Apr 6, 2014 at 11:38

3 Answers 3

2

tox creates a virtualenv in .tox/py27, .tox/py35 etc depending on the python versions you test with (i.e. based on you envlist in tox.ini or the argument to the -e option). tox then installs pip into this virtualenv, and your packages, and all packages your package is dependent upon.

On further runs, to save time, the virtualenv is reused and only your package is reinstalled (and possible dependencies updated). Your pip will stay at the original version unless you do:

./tox/py27/bin/pip install -U pip 

or reinitialises the complete virtualenv with:

tox -r -e py27 

(or tox -r for all .tox virtualenvs for all python versions in your envlist).

If you further want to analyse how tox does the setup, first call:

tox -r -e py27 -vv 

from the output you can see the recreate step:

py27 recreate: /src/site-packages/your/package/.tox/py27 removing /src/site-packages/your/package/.tox/py27 setting PATH=/src/site-packages/your/package/.tox/py27/bin:/opt/python/2.7/bin:........ /src/site-packages/your/package/.tox$ python -m virtualenv --python /opt/python/2.7.13rc1/bin/python py27 >/src/site-packages/your/package/.tox/py27/log/py27-0.log 

Now you go to the .tox directory and redo the virtualenv creation verbose:

cd .tox; rm -rf py27 python -m virtualenv --python /opt/python/2.7/13rc1/bin/python py27 

From that log you'll see that it uses the latest (cached) version of pip. As your normal install gets you the latest pip version, there should be no need to clean/update pip's cache.

Sign up to request clarification or add additional context in comments.

1 Comment

0

Can also try to define the pip version for the particular environment in the tox config file.

eg:

[testenv:py39] deps: -r requirements-dev.txt # Affect only py3.9 pip==21.3.1 

Comments

-2

Use this approach: create a tox.ini file at the same level as your setup.py and use it to tell tox which versions to run, like here

1 Comment

This does not answer the question. It is not the Python version which is sought but the pip one.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.