-
Notifications
You must be signed in to change notification settings - Fork 3k
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
pip fails to build project from backend-path
when MetaPathFinder
is present and installing from VCS url
#11812
Comments
By adding some debug statements to obj.__file__ = '/tmp/my_backend/my_backend.py'
extra_pathitems = ['/tmp/pip-install-akmokyzj/my-backend_6731a91a030b414da7bf6d41b4d958c8']
sys.path_hooks = [
<class 'zipimport.zipimporter'>,
<function FileFinder.path_hook.<locals>.path_hook_for_FileFinder at 0x7f31cda1b910>
]
sys.meta_path = [
<class '_editable_impl_my_backend._EditableFinder'>,
<_distutils_hack.DistutilsMetaFinder object at 0x7f31cd921f30>,
<class '_frozen_importlib.BuiltinImporter'>,
<class '_frozen_importlib.FrozenImporter'>,
<class '_frozen_importlib_external.PathFinder'>
]
sys.path = [
'/tmp/pip-install-akmokyzj/my-backend_6731a91a030b414da7bf6d41b4d958c8',
'/tmp/.venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process',
'/tmp/pip-build-env-bwdvn95z/site',
'/usr/local/lib/python310.zip',
'/usr/local/lib/python3.10',
'/usr/local/lib/python3.10/lib-dynload',
'/tmp/pip-build-env-bwdvn95z/overlay/lib/python3.10/site-packages',
'/tmp/pip-build-env-bwdvn95z/normal/lib/python3.10/site-packages'
] |
First off, I will say that this seems to me like a very unusual case. It does look like a bug, but I wouldn't consider it particularly high priority. I want to establish this up front because (see below) it seems rather hard to fix properly. This might be fixable by adding some extra logic to the injected And of course, we need to establish precisely what we're fixing here. "Use of import hooks like the way the At this point, I think that we'd be better just dumping the existing build environment approach and using |
Hi @pfmoore, thank you very much for having a look on this. I completely agree that it is a very specific scenario, and tricky to solve. Probably not high-priority either.
If there is an interest from I think that your suggestion of |
If the final conclusion is that this is a limitation we have to live with, would it be possible to at least drop the backend-path check? This is the check that halts the build. Another possibility would be for the frontend to actively import the backend from the right path by using |
OK, I'll go on record as in favour of using I do think that if we do that, we may have a fight on our hands around Debian not shipping venv as a default part of the system Python1. But I think we should make that Debian's problem - if venv isn't present, fail with a big message saying "your Python installation is incomplete. You should report this issue to your distributor (and in the meantime, look for a "python venv" package distributed by your OS to install)". Or we could use venv by default but keep the existing apprach as a fallback (without trying to fix this bug in it - there are limits!) But I'd be very sad if we did that, as it's to an extent the worst of both worlds. Footnotes
|
I'm +1 on using I think that Debian recommends the installation of An interesting thing, one of the reasons (and maybe the reason) that debian doesn't ship |
🙃 |
Apologies, I should have remembered that now @pradyunsg is a core developer, he has access to the keys to Guido's time machine 😉 |
FYI, we've merged a |
Oh nice! I'll take a look at it after spending some bandwidth on the resolver though! |
I opened a PR on pypa/pyproject-hooks#165 to improve the way My understanding is that |
Description
pip
will fail to build a project in the following circumstances:MetaPathFinder
(e.g. as if it was installed in editable mode) that is inserted beforeimportlib.machinery.PathFinder
.target
directory).Real-world scenario/motivation:
I run into this problem when trying to address pypa/setuptools#3806 and pypa/setuptools#3828. In those issues, users describe problems with the precedence of editable installs with
MetaPathFinder
. My initial approach was to "bump" the precedence by changing the insert position insys.meta_path
andsys.path_hook
.However, when running the tests with
pytest-perf
, I received an error message frompip
:Note that
pytest-perf
will install the project from the tracking VCS URL to use as a baseline for the performance comparison.References
Implementation: pypa/setuptools#3829
Failed tests: https://github.com/pypa/setuptools/actions/runs/4187531113/jobs/7257489290#step:7:646
Expected behavior
pip
would build the project in an isolated environment that is not contaminated by the virtual environment where pip is installed. This should be inline with PEP 517 description:(or at least use
importlib.util.spec_from_file_location
to ensure thebuild-backend
is loaded from the place specified inpyproject.toml > [build-system] > backend-path
)pip version
23.0.1
Python version
Tested in 3.10.6 and 3.10.9
OS
Tested in Ubuntu 20.04.5 LTS and also
python:3.10
container (Debian GNU/Linux 11 - bullseye)How to Reproduce
backend-path
MetaPathFinder
:Please note that the backend is not really invalid in this case... What happens is that the build frontend is loading it from a different location instead of loading it from
backend-path
.Output
Code of Conduct
The text was updated successfully, but these errors were encountered: