pip: 21.3: Breaking editable installation with `No module named pip` error
Description
Our CI is failing due to version 21.3 release, in the pip wheel subprocess call during installation, with seemingly random packages being the culprit.
E.g.
subprocess.CalledProcessError: Command '['/opt/hostedtoolcache/Python/3.7.12/x64/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpiq0bznxg', '--quiet', 'cryptography<3.5,>=3.4.1']' returned non-zero exit status 1.
Full Log attached below
The specific dependency it fails for seems completely random, in 5 subsequent runs it’s been pathspec, cryptography, tabulate, rdflib and pyasn1.
I can reproduce the issue locally as well with Arch Linux, 21.3 fails, 21.2.4 works.
This only happens in editable mode (using -e flag), without it everything install fine.
Expected behavior
Renku Package to be installed without problem
pip version
21.3
Python version
3.7.8
OS
Arch Linux/Github Actions(Ubuntu)
How to Reproduce
- clone https://github.com/SwissDataScienceCenter/renku-python
- upgrade to pip 21.3
- do
pip install -e .[all]
Output
$ python -m pip install -e .[all]
/home/user/.pyenv/versions/renku-python/lib/python3.7/site-packages/secretstorage/dhcrypto.py:16: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
/home/user/.pyenv/versions/renku-python/lib/python3.7/site-packages/secretstorage/util.py:25: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
Obtaining file:///home/user/DEV/ETH/renku-python
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build editable: started
Getting requirements to build editable: finished with status 'done'
Preparing editable metadata (pyproject.toml): started
Preparing editable metadata (pyproject.toml): finished with status 'done'
Build backend does not support editables, falling back to setup.py egg_info.
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /home/user/.pyenv/versions/renku-python/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/user/DEV/ETH/renku-python/setup.py'"'"'; __file__='"'"'/home/user/DEV/ETH/renku-python/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-0jfl5x91
cwd: /home/user/DEV/ETH/renku-python/
Complete output (31 lines):
/home/user/.pyenv/versions/renku-python/bin/python: No module named pip
Traceback (most recent call last):
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/setuptools/installer.py", line 75, in fetch_build_egg
subprocess.check_call(cmd)
File "/home/user/.pyenv/versions/3.7.8/lib/python3.7/subprocess.py", line 363, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/user/.pyenv/versions/renku-python/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpppr5o_gk', '--quiet', 'zc.relation<1.2,>=1.1']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/user/DEV/ETH/renku-python/setup.py", line 266, in <module>
"Development Status :: 4 - Beta",
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/setuptools/__init__.py", line 152, in setup
_install_setup_requires(attrs)
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/setuptools/__init__.py", line 147, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/setuptools/dist.py", line 809, in fetch_build_eggs
replace_conflicting=True,
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/pkg_resources/__init__.py", line 768, in resolve
replace_conflicting=replace_conflicting
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1051, in best_match
return self.obtain(req, installer)
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1063, in obtain
return installer(requirement)
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/setuptools/dist.py", line 877, in fetch_build_egg
return fetch_build_egg(self, req)
File "/tmp/pip-build-env-gh6wm4a4/overlay/lib/python3.7/site-packages/setuptools/installer.py", line 77, in fetch_build_egg
raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['/home/user/.pyenv/versions/renku-python/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpppr5o_gk', '--quiet', 'zc.relation<1.2,>=1.1']' returned non-zero exit status 1.
----------------------------------------
WARNING: Discarding file:///home/user/DEV/ETH/renku-python. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Code of Conduct
- I agree to follow the PSF Code of Conduct.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 19
- Comments: 28 (15 by maintainers)
Commits related to this issue
- fix(install): Use pip v21.2 A change in pip v21.3 causes `-e` in requirements.txt from a github repo to fail This is a temporary solution until https://github.com/pypa/pip/issues/10573 is fixed. — committed to MarkLark86/superdesk-core by MarkLark86 3 years ago
- fix(install): Use pip v21.2 A change in pip v21.3 causes -e in requirements.txt from a github repo to fail. This is a temporary solution until pypa/pip#10573 is fixed. — committed to MarkLark86/fireq by MarkLark86 3 years ago
- fix(install): Use pip v21.2 A change in pip v21.3 causes -e in requirements.txt from a github repo to fail. This is a temporary solution until pypa/pip#10573 is fixed. — committed to MarkLark86/fireq by MarkLark86 3 years ago
- fix(install): Use pip v21.2 A change in pip v21.3 causes `-e` in requirements.txt from a github repo to fail This is a temporary solution until https://github.com/pypa/pip/issues/10573 is fixed. — committed to MarkLark86/superdesk-core by MarkLark86 3 years ago
- fix(install): Use pip v21.2 (#2284) * fix(install): Use pip v21.2 A change in pip v21.3 causes `-e` in requirements.txt from a github repo to fail This is a temporary solution until https://githu... — committed to superdesk/superdesk-core by MarkLark86 3 years ago
- requirements: pin pip to 21.2.4 See https://github.com/pypa/pip/issues/10573. — committed to istankovic/raiden by deleted user 3 years ago
- .circleci: pin pip to 21.2.4 See https://github.com/pypa/pip/issues/10573. — committed to istankovic/raiden by deleted user 3 years ago
- .circleci: pin pip to 21.2.4 See https://github.com/pypa/pip/issues/10573. — committed to istankovic/raiden by deleted user 3 years ago
- .circleci: pin pip to 21.2.4 See https://github.com/pypa/pip/issues/10573. — committed to raiden-network/raiden by deleted user 3 years ago
- [SDESK-6199]: Add `original_id` to Content API items (#2282) * [SDESK-6199]: Add `original_id` to Content API items * Set `original_id` before checking parent * fix(install): Use pip v21.2 A c... — committed to superdesk/superdesk-core by MarkLark86 3 years ago
- Pin pip to avoid pypa/pip#10573 — committed to zklaus/esmvalcore-feedstock by zklaus 3 years ago
- Pin pip!=21.3 to avoid pypa/pip#10573 with editable installs — committed to ESMValGroup/ESMValCore by zklaus 3 years ago
- Pin pip to avoid pypa/pip#10573 — committed to ESMValGroup/ESMValTool by zklaus 3 years ago
- bib/install: disable pip self ugprade This is both a temporary fix for https://github.com/pypa/pip/issues/10573 , which currently breaks entirely our developer seutp, and also a saner approach to fut... — committed to SoftwareHeritage/swh-environment by zacchiro 3 years ago
- jobs/swh-environment: Simplify build script and workaround pip issue The bin/install script from swh-environment has been updated to install swh dependencies in a same manner as in the build script s... — committed to SoftwareHeritage/swh-jenkins-jobs by anlambert 3 years ago
- Pin pip!=21.3 to avoid pypa/pip#10573 with editable installs (#1359) — committed to ESMValGroup/ESMValCore by zklaus 3 years ago
- Try dropping editable installs see: https://github.com/pypa/pip/issues/10573 — committed to joshmoore/zarr-python by joshmoore 3 years ago
- Handle legacy nested datasets (with tests) (#850) * Fix #840 * Add legacy tests (See #840) Each fixture (flat & nested) should have a version which does not include any new metadata. * Fix ... — committed to zarr-developers/zarr-python by joshmoore 3 years ago
- Fix problem with pip 21.3 that prevents installation from source (#2344) * Add test-fix branch to ga * Pin pip to avoid pypa/pip#10573 — committed to ESMValGroup/ESMValTool by zklaus 3 years ago
- Pin pip==21.2.4 See https://github.com/pypa/pip/issues/10573 — committed to mkoura/cardano-clusterlib-py by mkoura 3 years ago
I guess you could create a tracking issue on your bug tracker and link to the pip issue there to reduce flooding - people shouldn’t be discouraged from adding context to their commits because of how GH does references.
@zklaus @swhmirror @istankovic Please avoid mentioning issues repeatedly from another repository, these messages are spamming the issue.
In the meantime, a possible workaround is to use
pip install -e . --no-use-pep517when you have a setup.py that has a setup_requires and also a pyproject.toml.Alright, I I’m slowly nailing it…
A minimal reproducer for this is an empty
pyproject.tomland asetup.pywith anysetup_requires.I missed the fact that
setup.py developis running in an isolated build (!) environment if there is apyproject.toml🤷. I thought editable were totally independent of PEP 518/517 things until PEP 660, and this false assumption partly misled my PEP 660 implementation…According to the changelog, this dates back to #4999. This presumably done so pip installs
setup_requiresrequirements and not setuptools (which back then was not using pip) ?Since the default implementation of
get_requires_for_build_editablereturns [], pip does not install the setup_requires, and setuptools attemps to do it by itself… in the isolated environment which does not have pip.I’m pushing a hack commit to #10577 to let my thoughts settle down but I think I’ll have to re-do metadata preparation to detect the missing get_requires_for_build_editable hook and fall back to regular metadata preparation much earlier.
Unrelated to this issue, see my comment at https://github.com/omry/omegaconf/pull/800.
I can also confirm that #10577 fixes it
fluidsim (also using pyproject.toml + setup.py with setup_requires) is also affected by this regression. I confirm that #10577 fixes it!
@sbidoul sorry, was too fast with typing and too slow with reading. Thx for the support!
Ok, this seems to be related to the PEP 660 implementation.
Since this project has a pyproject.toml without build-system table, it seems that pip<21.3 did first prepare the metadata using the
setuptools.build_meta:__legacy__build backend, then calledsetup.py develop, so doing a mix of PEP 517 and legacy installation.Now pip first tries a PEP 660 editable metadata preparation and, since the build backend does not support PEP 660, it falls back to a legacy metadata preparation (
setup.py egg_info), which should in theory be equivalent but, for some reason I don’t fully understand, does not work for your project.