pip's vendored pkg_resources should stop using pkgutil.ImpImporter
See original GitHub issueDescription
pkgutil.ImpImporter
has been deprecated since Python 3.3. It is slated to be removed in Python 3.12 but until pip
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
- Grab the CPython branch:
gh pr checkout 98059
- configure && make test
test_venv
fails becausepip
uses this API- See https://github.com/python/cpython/actions/runs/3215689824/jobs/5256965254
Output
No response
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Update vendored packages for 22.3 · Issue #11500 · pypa/pip · GitHub
So while I can point out where things don't work on Windows, I'm pretty lost ... pip's vendored pkg_resources should stop using pkgutil.ImpImporter...
Read more >blob
The package resource API is designed to work with normal filesystem packages, .egg files, and unpacked .egg files. It can also work in...
Read more >Daiyi Zhuang
The package resource API is designed to work with normal filesystem packages,. 13 .egg files, and unpacked .egg files. It can also work...
Read more >pkgutil — Package extension utility
Because the place where the package stops and the object hierarchy starts can't be inferred by inspection, repeated attempts to import must be...
Read more >Issues with pip - python
Check your PYTHONPATH environment variable. On Linux you can do echo $PYTHONPATH . Turns out my PYTHONPATH had several locations to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.
https://github.com/pypa/pip/blob/8f381cd439ff3ded9d124ba23ecb1c2581c008ed/src/pip/_vendor/vendor.txt#L19
https://github.com/pypa/pip/issues/11500#issuecomment-1272683142 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 https://github.com/pypa/pip/pull/11502 (or a follow up); assuming it’s tractable in the limited free time that I have. 😃