14

I am using tox to manage some testing environments. I have a dependency (backports.ssl-match-hostname) that I cannot download using the latest version of pip, so I need to revert back to pip 8.0.3 to allow the install to work.

I have included the 8.0.3 version of pip inside my tox.ini file for dependencies.

deps=
    pip==8.0.3

However, when I run

source .tox/py27/bin/activate

and enter the virtual testing environment, and then run

pip --version

I end up with

8.1.2

However, outside of my tox environment, when I run the same command, I get

8.0.3

Is there anything special that tox does when grabbing pip? Why am I not able to specify the version of pip that I want to use as a dependency?

EDIT : to add to this, it seems as though I am able to grab the dependency pip==8.0.3, but for the other dependencies, they are still running from the command launched with pip==8.1.2

So, I need to be able to grab pip==8.0.3 first, and then once installed, grab everything else. Still unsure why tox is starting with pip==8.1.2

Zack
  • 13,454
  • 24
  • 75
  • 113

4 Answers4

8

This was apparently the result of the "virtualenvs" python package containing a pre-selected group of python packages that it refers to, one of which was the latest and greatest pip.

I don't know if this is the preferred way of doing this, but I found success by running

pip uninstall virtualenv

And then reinstalling with the version that worked

pip install virtualenv==15.0.1

With the "correct" version of virtualenv in place, I was able to run my tox command

source .tox/py27/bin/activate

and see the desired version of pip

pip --version
pip 8.0.3
Zack
  • 13,454
  • 24
  • 75
  • 113
  • 1
    I have found it is important to uninstall existing virtualenv, because pip is bundled in virtualenv_support package, which is not being updated with update of virtualenv – Sergey Panfilov Sep 02 '16 at 09:24
4

A workaround for this is here: https://github.com/pypa/pip/issues/3666

Although to make it work I had to write "pip install pip==8.1.1" in my script. So to recap:

Add a pip.sh script to your project:

#!/bin/bash
pip install pip==8.1.1
pip install "$@"

Add to your tox.ini:

install_command = {toxinidir}/pip.sh {opts} {packages}
boxed
  • 3,895
  • 2
  • 24
  • 26
0

I've recently hit this problem. I've had it for a while but it just didn't register because I had such occasional failures with Python 2/3 code. Another way that this can happen is, if like me, you change the virtualenv between different Python versions and don't clean up.

Check /bin or /Scripts to see whether python2 points to python. If the virtualenv is Python 3 then this will mean that python2 actually calls Python 3. Vice versa, of course, if you the virtualenv is Python 2 and you want to test Python 3 code.

Charlie Clark
  • 18,477
  • 4
  • 49
  • 55
0

New versions of virtualenv reach out to download the latest pip, setuptools, and wheel -- you can disable this behavior when running through tox with the tox-virtualenv-no-download package See: https://github.com/asottile/tox-virtualenv-no-download#wait-why

Max Gasner
  • 1,191
  • 1
  • 12
  • 18