Currently it appears tox always installs the latest pip when (re)creating virtualenvs.
However sometimes (like today) the latest version doesn't work, or you haven't yet accounted for breaking changes.
Tox should have a way to control the version of pip.
Perhaps a pip_version config property, or allowing install_command to be multiple lines.
The _latest_ behaviour here is due to virtualenv's downloading behaviour. If you want a more "consistent" version, I might suggest using tox-virtualenv-no-download#wait-why.
Related: #448
The latest behaviour here is due to virtualenv's downloading behaviour.
Is that still accurate ? Since today (new release?!), some of our AppVeyor builds (Python 2.7 builds) fail with an outdated pip version.
The issue is explicit:
[...]
File "C:\projects\scapy\.tox\py27-windows\lib\site-packages\pip\_vendor\_markerlib\markers.py", line 113, in marker_fn
return eval(compiled_marker, environment)
File "<environment marker>", line 1, in <module>
File "<environment marker>", line 1, in <module>
NameError: name 'platform_system' is not defined
You are using pip version 8.1.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
=================================== log end ===================================
ERROR: could not install deps [mock, setuptools>=18.5, cryptography, coverage, python-can]; v = InvocationError(u"'C:\\projects\\scapy\\.tox\\py27-windows\\Scripts\\python.EXE' -m pip install mock 'setuptools>=18.5' cryptography coverage python-can", 2)
I bumped into https://github.com/tox-dev/tox/issues/765 then here :/
soon you can override the default version into pip, in the meantime please upgrade virtualenv alongside tox to get later defaults.馃憣
And yes with the latest version we no longer download latest pip.
When installing tox use the force reinstall flag to get latest virtualenv 馃榾
Thanks for this light-speed answer :smile:
Does tox uses the pip version of the virtualenv ?
I'd rather only update pip
tox creates virtual environments that have their seed packages (pip, setuptools, wheel) with the version bundled within the virtualenv installed alongside it. you can of course use the deps then to upgrade to install another version. Or just upgrade virtualenv to have newer bundles.
There is https://github.com/pglass/tox-pip-version which does what this issue requests, I believe
GitHub
A tox plugin to select your pip version. Contribute to pglass/tox-pip-version development by creating an account on GitHub.
you can of course use the deps then to upgrade to install another version
@gaborbernat This doesn't actually work in my experience. It will install a version of pip, yes, but tox will not actually use that new version of pip to install the rest of the dependencies.
The reason is because tox runs _one_ pip command to install everything, like python -m pip install pip==19.1 requests (see example below). It won't start using pip version 19.1 until the _next_ pip command is run.
[testenv]
deps =
pip==19.1
requests
Some other things I've tried:
install_command = pip install -U 'pip==18.1' {opts} {packages} has the same issue. It is true that if you install a specific version of virtualenv prior to running tox, you can change the effective version of pip that tox uses to install packages. But, this still falls short in some ways:
tox-venv, which uses python -m venv instead of the virtualenv packageHence, I did make a plugin for this (see previous comment), but it would be much nicer for this to be a native feature.
This will be fixed on the virtualenv side, I'm actively working on https://github.com/pypa/virtualenv/issues/1366, I hope to have something by the end of the month.
Any update on that? I am looking for a workaround that can be used today, without waiting for a newer version of virtualenv.
@ssbarnea do you want "latest" -- you can re-enable virtualenv's downloading by setting the testenv download option:
[testenv]
download = true
No direct progress on this. Made some progress on the tox rewrite that will allow me to test the virtualenv rewrite... Coming along but this is a major effort (fixing a lot of hard issues while at it - e.g. lazy configuration load), so probably will last into September.
FWIW I'm using tox-venv because I've had some trouble with virtualenv in the past. This means I get whatever pip which ships with Python's ensurepip (as of Python 3.8.1, that's pip 19.2.3). However, I needed to install manylinux2014 wheels, which requires pip 19.3...
Installing tox-pip-version and setting pip_version = pip in [testenv] to get the latest pip worked beautifully - thanks @pglass! :tada:
tox-venv will become obsolete once https://github.com/pypa/virtualenv/pull/1481 lands, and that will also solve this issue on virtualenv side 馃憤
I've been hearing about virtualenv rewrites for the past five years or so, so I wonder how this one turns out - good luck! :crossed_fingers:
This one is very close to ship-able, 馃槉 so will actually happen, the latest end of February! I'm fully committed now to deliver it.
Updating virtualenv that is installed alongside tox may not be an option since it may not support target python.
E.g. my host Python is 3.7 and my target Python is 2.6 / 3.4. Therefore I can install the most recent tox, but I cannot install the most recent virtualenv with most recent virtualenv dependencies.
Hello @Kentzo sadly we no longer support Python2.6, even at the target level. Python3.4 should still work.
I just hope that this issue will not resurface in the future. tox's dependency on virtualenv_support is a major PITA.
Not sure what alternatives you're proposing here 馃し鈥嶁檪
Ability to update pip / setuptools / etc inside bootstrapped virtualenv before installing any of the deps. Perhaps an ability to execute arbitrary shell code.
Definitely no to arbitrary shellcode; ability to do those via virtualenv will be provided; to be fair it already is via the --download flag of virtualenv.
This should be now possible by setting VIRTUALENV_PIP=19.0.0 with virtualenv 20.
This should be now possible by setting
VIRTUALENV_PIP=19.0.0with virtualenv 20.
@gaborbernat is there a way to tell tox what version of virtualenv to use? Or do we have to make sure people are running virtualenv 20+ another way?
You can use the requires key in the configuration.https://tox.readthedocs.io/en/latest/config.html#conf-requires
Most helpful comment
@ssbarnea do you want "latest" -- you can re-enable virtualenv's downloading by setting the testenv
downloadoption: