-
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's vendored pkg_resources should stop using pkgutil.ImpImporter #11501
Comments
However! pip 22.2.2 still relies on pkgutil.ImpImporter so these things cannot be removed until this issue is resolved: pypa/pip#11501
|
Thanks for filing this @warsaw! This module is under
I believe this needs to get fixed there, and we'll pick up the fix once it's made there. :) |
@warsaw Could you file an issue against https://github.com/pypa/setuptools for this? |
/cc @jaraco for visibility, since setuptools "owns" pkg_resources and would need to make the relevant changes on this front. |
/cc @pfmoore for awareness as the current RM -- to be clear, I don't know this affects any of the plans for the current release. I'm flagging this for awareness since there is, maybe, a chance that there's a setuptools release after we make this time's round of updates and before the release, in which case we might want to run another vendoring update. :) |
Thanks @pradyunsg; I'll do this, although I'm not sure how to figure out which version of |
See the referenced |
So... this issue made me realise that I'd broken our update logic in a subtle manner, which means we're on a ~2 year old version. pip/src/pip/_vendor/vendor.txt Line 19 in 8f381cd
#11500 (comment) is where I noticed that. I'll be trying to bump to the latest setuptools version in the next pip release, as a part of #11502 (or a follow up); assuming it's tractable in the limited free time that I have. :) |
Since we are already moving from pkg_resources to importlib.metadata, we can make Python 3.12 our cutoff to switch entirely to the latter backend. This would mean that we can simply keep pkg_resources as-is since those usages will only be accessed on earlier Python versions. |
Does this need further work after #11689 is successfully implemented? |
The change landed in setuptools 66.1, so I'd say not yet. |
What are the chances of updating the |
So, I guess we're at an impasse. We can't remove these long deprecated APIs without fixing the stack of dependencies vendored into CPython. Time's also getting short for Python 3.12 and it will be sad if we can't make progress on this for another year. Any thoughts on how to proceed? |
I'll work on this. |
OK, the fix is now merged and I'll do the release tomorrow (UK time) - in 12 hours or so. Hopefully, that will be the last iteration we'll need on all of this! Thanks everyone for the discussion and your patience! |
Pip 23.1.2 has now been released. |
Reading the above discussion, I am unsure if this should be considered fixed. Either way, I am using pip 23.1.2 on Python 3.12.0b1 via pyenv on Windows 10, and I am unable to install matplotlib or numpy:
I have done the tour via pypa/setuptools#3631 and #11688 all the way to here, which is the only issue still open. |
This looks like a setuptools issue. pip does not import setuptools unless the package tells it to, so this is something you should report to either setuptools or the packages using it and triggering the error. |
I suspect that To make sure the package builds on Python 3.12, the best would be to use a relatively recent version of setuptools. This is probably specified in the |
Ah, this seems to be the key thing, because I have setuptools 67.8.0 installed but that is irrelevant. So this explains why But this does not explain why |
I am not sure how the dependency resolution algorithm works during build time, but matplotlib seems to depend on numpy, there might be a chance the same environment is being used to build both and then the same version of setuptools would be used? @uranusjr might be more familiar with the dependency resolution at this stage... |
You are right - even at build time: Okay, that explains that as well. I guess I will open an issue with numpy then. |
With #11997 landed, is there anything more needed here |
Otherwise we run into a Python 3.12 incompatibility with pkg_resources: pypa/pip#11501 Also needs PIP_REQUIRE_VIRTUALENV=0 because otherwise pip seems to falsely assume it's installing things system-wide, weirdly. Should probably be removed once there is a newer virtualenv, which vendors a newer pip, which vendors a newer pkg_resources... See #7727
How do I fix pip not being able to install anything or do pip freeze. I have faced it several times, where in python3.12 pip is working normally but after some commands, it doesnt work and cpython have to reinstalled through git clone. python/cpython#106824 |
We already fixed this in pip 23.2 actually (since the bundled (Edit: the bundled pip in CPython has since been updated to 23.2.1 on 2023-07-25. See python/cpython@f443b54) |
Description
pkgutil.ImpImporter
has been deprecated since Python 3.3. It is slated to be removed in Python 3.12 but untilpip
no longer uses it, we probably can't remove this long deprecated class.Expected behavior
No response
pip version
22.2.2
Python version
3.12
OS
macOS
How to Reproduce
gh pr checkout 98059
test_venv
fails becausepip
uses this APIOutput
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: