-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
ensurepip
fails with importlib.metadata
backend
#11183
Comments
Huh, pip/src/pip/_vendor/pkg_resources/__init__.py Lines 1978 to 1981 in dc7abca
As you can tell from comment, the logic is pretty outdated and is arguably a bug, but this is relied by pip and “works”. I’ll work on a fix to do this properly. |
Should ensurepip use |
ensurepip probably should use |
I took a look at the code. It assumes that repeated calls don't reinstall. So I guess this would need to check if pip and setuptools is installed first and if at least one of them is not, pass |
I'd lean toward not "fixing" this via ignoring the dist-info, and I think we should instead update ensurepip to work the way get-pip.py does. Is there any reason to not do it this way? |
get-pip always uses |
I didn't mean in terms of the flags passed, but rather in terms of how we're putting a copy of pip on sys.path. I don't think we should be trying to use pip while it's packaged in a wheel -- we know that's fragile in multiple ways and something that we don't support users doing either. |
There’s good justification to ignore |
Indeed, let's do both then. :) |
@uranusjr @pradyunsg coming here by reading the 22.2 release notes.
Could it be a problem that pip and importlib.metadata have a different view of what an installed distribution is ? |
I think it's simply a difference in how things are viewed. |
I think it's something that could do with clarification somewhere, but it's not a problem as such. My view is that pip is working with installed packages, whereas importlib is working with accessible packages. That's a subtle but important distinction, which we've never formalised so far. Is adding a directory to The important aspect of PEP 376 that never really made it into core Python was the idea that there is some sort of database of "installed" packages, and "installed" means something different than "accessible". Maybe that's because core Python genuinely doesn't need to care, and "installed" is entirely a packaging concept? Footnotes
|
Interesting. So I went looking in the python docs and the importlib.metadata page actually starts with a definition of what an installed package is.
It's still vague in terms of what discoverable means though. Yet that could be something we'll need to chew on... |
I hadn't spotted that (TBH, I tend to find the This starts to tie back into the idea of #4575 and #6052 around cleaning up the idea that we install into an "installation scheme". I think that it would be really useful for pip to formalise exactly what set of directories (the scheme) it's managing on any given run, and tie questions like this back to that formalisation. So we'd frame the current problem as " |
Description
In Debian, we use the pip from our pip package with
ensurepip
. We've noticed with3.11
, and pip22.1.1
, ensurepip isn't doing anything any more.The relevant change is that the
importlib.metadata
is the default backend with Python 3.11. If we force it back to thepkg_resources
backend, it works.Expected behavior
ensurepip
is expected to install pip. It doesn't do anything, any more.pip version
22.1.2+ dc7abca
Python version
3.11+ f9d0240db809fbb4443dc8f96a18e4c49af3fb7f
OS
Linux
How to Reproduce
ensurepip/_bundled/
in your Python installation._PIP_VERSION
inensurepip/__init__.py
to refer to the new version.python3.11 -m venv testve
ls testve/lib/python3.11/site-packages/
This should not be empty, but will be.
For extra debugging:
testve/bin/python -Im ensurepip --upgrade --default-pip -v
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: