New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ubunutu 16.04 + system python-virtualenv = borked virtualenv which doesn't work. #325
Comments
xref pypa/setuptools#2004 which I think is the same thing |
I assume that this is the root of the problem, |
Debian 8 has a similar problem (if you try to update pip in a virtual environment, it will happily install one that won't actually run on Python 3.4, as the system pip is too old to respect Python-Requires). My workaround was to make the environment without pip, then install "pip < 19.2" (19.2 was the first version that required 3.5). After that, pip in the venv is new enough to respect Python-Requires, so everything sorts itself out. (Debian 9 and Ubuntu 18.04 have new enough system pip versions that this problem doesn't come up) |
I can't reproduce that, I get 45.0.0. In a clean Ubuntu 16.04 (Xenial) chroot: # apt install python-virtualenv
...
(xenial-amd64)stefanor@elgar:/$ cd /tmp/
(xenial-amd64)stefanor@elgar:/tmp$ virtualenv venv
Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/venv/bin/python2
Also creating executable in /tmp/venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
(xenial-amd64)stefanor@elgar:/tmp$ venv/bin/python -c 'import setuptools; print setuptools.__version__'
45.0.0 Can you describe more about what workflow this breaks? |
@stefanor OP tries to upgrade setuptools with pip after creating the virtualenv. You didn’t. |
Dare I say "don't do that, then?" The latest setuptools isn't compatible with Python 2.7. There is no newer version that is compatible. If you try to upgrade it, it's telling you that there's nothing useful it can do:
I don't know what behaviour you're desiring? |
Uh… sure? I mean, that’s basically what comments above yours were trying to explain (without using the exact wording). |
Oh, I misread the changelog 45.0.0 is not supposed to be compatible with Python 2.7, either. @ncoghlan: In Debian 8 (jessie), you get an older pip and setuptools, bundled in python-pip-whl. It looks like the mechanism for using that wasn't working in Ubuntu Xenial, so you get closer to the latest versions, there. (Probably more accurately: It wasn't doing an upgrade after using the bundled pip). But upgrading pip and then setuptools seems to do the right thing, as long as you do it in this order. I don't think you need to make the environment without pip:
|
Ok, I might have been wrong in my previous assessment of the bug, or confused with some other installation I've done. Anyhow, now I think this is an PYPA bug not an Ubunutu/Debian, one, setuptools 45.0.0 which does NOT support python2 (it has inside requierments >=3.5), has the filename in pypi: PYPA should remove the setuptools 45.0.0 from pypi and put a version which isn't marked as py2, and this will fix all the problems I think. |
Aha, well spotted. Yeah, removing that (and replacing with a py3 non-universal version) would be the simplest. |
OK, now I understand why I'm confused, on Ubuntu 16.04 with python-virtualenv: # virtualenv venv1
# venv1/bin/python -c "import pip, setuptools; print(pip.__version__, setuptools.__version__)"
('20.0.2', '45.0.0')
# virtualenv venv2 --no-download
# venv2/bin/python -c "import pip, setuptools; print(pip.__version__, setuptools.__version__)"
('8.1.1', '20.7.0')
# venv2/bin/python -m pip install setuptools -U
# venv2/bin/python -c "import pip, setuptools; print(pip.__version__, setuptools.__version__)"
('8.1.1', '45.2.0') I cannot understand why in venv1 it goes to 45.0.0 and in venv 2 it goes to 45.2.0 (both are using the same debian/ubuntu vendored pip 8.1.1 for the task. There might be a few issues at play here, but one of them is that pypi is currently distributing a wrong version of setuptools 45.0.0 which is marked as compatible with python 2 while it is not. Since the most common use case where people create a virtualenv is like venv1, replacing the pypi file setuptools-45.0.0-py2.py3-none-any.whl with setuptools-45.0.0-py3-none-any.whl would hopefully solve most of the problems people are currently having. That will also get them an updated pip 20.0.2 which will take care of the rest. As for why the --no-download virtualenv get's to 45.2.0 it might be a different bug (or ont), but then people will still having the old buggy pip and it's up on them to first upgrade to a saner pip before setuptools (altough it's an issue as well). In conclusion, can somoene from setuptools / pypa fix the wrong setuptools 45.0.0 package on pypi ? (or someone check that that will fix the main issue) ? |
@stefanor as for SRU virtualenv, there is another case of people who use "python-pip" to pip install packages on their --user dir (they are still using pip 8.1.1 if they didn't pip upgrade in their user dir), but maybe you can't save everyone. |
After chatting with @pganssle, I think the right approach would be to remove Since the files will have the same hash, this will prevent any disruption to users that have (correctly) pinned their hashes for this version, and should make |
The virtualenv patch could look something like: --- a/virtualenv.py
+++ b/virtualenv.py
@@ -971,7 +971,10 @@
fp.write(whl)
if not no_setuptools:
- to_install.append('setuptools')
+ if sys.version_info[0] < 3:
+ to_install.append('setuptools<45.0.0')
+ else:
+ to_install.append('setuptools')
to_install.append('pkg_resources') But I think fixing Xenial's (non-virtualenv) pip package would require backporting support for Requires-Python. That's probably not a trivial patch. |
I am somewhat skeptical of this solution. I think it's a possibility if we know it won't be disruptive, but I am not entirely sure what workflows are out there that may use the filename in their lockfiles (or be relying on the existence of the file on PyPI, like a direct link). Also, I'm not entirely sure if or why it would work. I would expect Can anyone explain why this is falling back to version 45.0.0 instead of hitting either 45.2.0 or 44.0.0? |
Looking at the index https://pypi.org/simple/setuptools/, 45.0.0 is the last to be labelled with |
I can reproduce finding 45.0.0 with |
Sure, but if you're setting options then that doesn't help anything, right? There are tons of workaround for people willing to pass flags to their virtual environments or whatever, and they are documented clearly in this thread so anyone can find them. The only value for taking the potentially disruptive action of modifying an existing Edit: Oops, I didn't see that you said |
setuptools 45.0.0 is getting installed by virtualenv from here https://github.com/pypa/virtualenv/blob/15.0.1/virtualenv.py#L829-L900 args = At that point, these wheels are installed: CacheControl-0.11.5-py2.py3-none-any.whl Edit: Debian has some patches to virtualenv, so https://salsa.debian.org/python-team/modules/python-virtualenv/-/blob/patched/15.0.1+ds-3/virtualenv.py#L849-921 is probably better to look at. |
Actually, backporting Requires-Python support (pypa/pip#3877) was trivial and will fix standalone pip as well as virtualenv, for Xenial. So, started the SRU process: https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1864766 Edit: Uploaded, waiting for the SRU team to approve it. Then it gets a week of ageing and testing, before releasing. |
Thank you for providing feedback on Python packaging!
To help us help you, please fill out as much of the following as you can. If a question is not relevant, feel free to skip it.
Ubuntu 16.04 (Works ok on Ubunutu 18.04)
Python 2.7.12 (Ubuntu 16.04 system)
None (inside the borked virtualenv it's the latest pip version, currently 20.0.2)
To bootstrap python-virtualenv uses an Ubuntu modified pip 8.1.1 version....
setuptools 45.0.0 (in pypi) and above bork environments which are based on ubuntu 16.04 and the system python-virtualenv package.
As you can see, because python-virtualenv uses the modified ubuntu 16.04 pip wheel which is version 8.1.1 to bootstrap the environment, it downloads the latest setputools from pypi (currently 45.2.0), and then any package which depends on setuptools (besides having the wrong version) will hard fail with this error:
This seems like a pretty popular and major workflow which simply stopped working...
The text was updated successfully, but these errors were encountered: