virtualenv: Setuptools v45.0.0 breaks virtualenv on Python 2
Foreword: I am quite familiar with the whole January 1st, 2020 deadline and am in the process of dropping Python 2 across all my projects, but this surprise from setuptools is quite inconvenient regardless. If you chose not to fix this, I will not judge anyone, but please don’t lecture me about Python 2 being deprecated 😃
All my automated virtual environment creation scripts on Python 2 started breaking today.
Here is an example:
$ py -2.7-32 -m virtualenv foo
…
UnsupportedPythonVersion: Package 'setuptools' requires a different Python: 2.7.8 not in '>=3.5'
…
OSError: Command …\Scripts\python.exe - setuptools pip wheel failed with error code 1
This seems to be caused by the release of setuptools v45.0.0 yesterday:
v45.0.0: 11 Jan 2020
1458: Drop support for Python 2. Setuptools now requires Python 3.5 or later. Install setuptools using pip >=9 or pin to Setuptools <45 to maintain 2.7 support. 1959: Fix for Python 4: replace unsafe six.PY3 with six.PY2
https://setuptools.readthedocs.io/en/latest/history.html#v45-0-0
It seems that, by default, virtualenv tries to install the latest setuptools and that pip install setuptools picks up setuptools>=45.0.0 even though these versions don’t support Python 2.
As a workaround, I am now using the following commands:
$ py -2.7-32 -m virtualenv --no-setuptools foo
$ foo\Scripts\python -m pip install "setuptools<45"
I’m no export in Python packaging, but I would expect setuptools>=45 to declare it doesn’t support Python 2 in its distribution metadata and that pip install setuptools would automatically detect that and avoid it, but this doesn’t seem to be the case.
If that is not possible, maybe versions of virtualenv for Python 2 should avoid setuptools>=45?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 15
- Comments: 18 (7 by maintainers)
Commits related to this issue
- Workaround for broken pip package This should be a temporary fix for broken setuptools/virtualenv: https://github.com/pypa/virtualenv/issues/1493 Buddy: Vittorio — committed to wrld3d/wrld-themes by StefanoFrazzetto 4 years ago
- Keep build-scripts compatible with python2 by limiting setuptools <45 ref: https://github.com/pypa/virtualenv/issues/1493 — committed to thelastpickle/cassandra-builds by michaelsembwever 4 years ago
- Fix Setuptools v45.0.0 error pip install setuptools picks up setuptools>=45.0.0 even though these versions don't support Python 2 (see discussion on https://github.com/pypa/virtualenv/issues/1493) T... — committed to coglinev3/ansible-role-ansible_container by coglinev3 4 years ago
- setup: install setuptools < 45 for py2 see also https://github.com/pypa/virtualenv/issues/1493 Signed-off-by: Kefu Chai <kchai@redhat.com> — committed to tchaikov/ceph-deploy by tchaikov 4 years ago
- setup: install setuptools < 45 for py2 see also https://github.com/pypa/virtualenv/issues/1493 Signed-off-by: Kefu Chai <kchai@redhat.com> — committed to tchaikov/ceph-deploy by tchaikov 4 years ago
- setup: install setuptools < 45 for py2 see also https://github.com/pypa/virtualenv/issues/1493 Signed-off-by: Kefu Chai <kchai@redhat.com> — committed to tchaikov/ceph-deploy by tchaikov 4 years ago
The following worked for me getting out of this issue.
pip install --upgrade ‘setuptools<45.0.0’
@ostefano It was the same for me. I worked around this by installing
setuptoolsexplicitly:However this is still critical when creating a new virtual environment for python 2.7, since
virtualenvwould downloadsetuptools-45.0.0, and no upgrade (downgrade via pip withpip install --upgrade 'setuptools<45.0.0') would actually remove it. Only solution is to download the wheel manually.