-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
pkg_resources
: Flip import conditionals around pkgutil.ImpImporter
and importlib.machinery.FileFinder
#3685
Conversation
a85759c
to
93ce5a0
Compare
Can confirm the issue on Python 3.12-dev. I stumble upon it running some |
@abravalheri Just from a visual inspection of the diff, it looks pretty good. Thanks. I'll try to find some time to actually build the branch and plumb it through to see if any other problems arise. |
Running
I also don't know how to create a |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with this change, although it leaves it to users to encounter it in Python 3.12. Presumably, they've been encountering deprecation warnings previously, so it's probably safe to remove support for it, but I'm also fine with just being cautious.
This issue reminds me that we really need to remove setuptools' dependence on pkg_resources so that the whole pkg_resources can be deprecated and removed.
Hi @jaraco thank you very much for having a look. I don't get exactly what you mean by Later we can keep working for the removal of |
FileFiler should always be present in Python 3.3+
1d0ac6d
to
87518dd
Compare
Thank you very much @warsaw for checking the PR. I just rebased the PR so I am hopping some of the errors you are seeing got solved. I am not exactly sure which tests are failing in your setup (maybe the relevant parts of the test logs got removed out accidentally?). With the rebase, I can successfully running the following: docker run --rm -it python:3.12-rc-bullseye /bin/bash
git clone https://github.com/abravalheri/setuptools -b issue-3631 /tmp/setuptools
cd /tmp/setuptools
python -m venv .venv
.venv/bin/python -m pip install -U pip tox
.venv/bin/tox -- -p no:cov -p no:perf -p no:flake8
# ...
# ====================================== 1115 passed, 29 skipped, 10 xfailed, 2 xpassed, 1 warning in 67.06s (0:01:07) =======================================
# .pkg: _exit> python /tmp/setuptools/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta
# python: OK (88.86=setup[21.35]+cmd[67.51] seconds)
# congratulations :) (88.95 seconds) Here I am disabling the following plugins:
Of course this may not be very representative because the container corresponds to an old snapshot for Python 3.12 development. Also, in macOS things may be very different (I am afraid I don't have access to this system to test). If the tests for |
Older versions of setuptools fail to import distutils on Python 3.12, presumably due to the removal of distutils from the standard library. This bug was fixed in pypa/setuptools#3685, and setuptools 66.1 was the first version released that includes the fix. (I'm not sure exactly how that PR fixed the bug, but it doesn't matter.) Because setuptools 66.0 understandably does not declare itself to be incompatible with Python 3.12, I'm recording that constraint here.
Summary of changes
importlib.machinery.FileFinder
is always present, therefore we no longer need to keep the conditionalpkgutil.ImpImporter
is removed, so we need a conditional to avoid using it directly.(Potentially) closes #3631
Notes
pkg_resources
usespkgutil.get_importer
to find out which importer is responsible for importing an specific file.Python >= 3.7, < 3.12
where this function can return an instance ofpkgutil.ImpImporter
.pkgutil.get_importer
never returnspkgutil.ImpImporter
, I believe we could simply removepkgutil.ImpImporter
from the namespace handler and finder registries inpkg_resources
(but don't quote me on that 😅).find_module
will be removed in 3.12.pkg_resources
use this function just as a contingency in the casefind_spec
is not defined.zipimporter
inPython >=3.7, < 3.10
Python >= 3.12
,find_spec
should always be defined, and therefore I believe the code path is not triggered.pkg_resources.find_on_path
andpkg_resources.file_ns_handler
ignore theimporter
argument.Pull Request Checklist
changelog.d/
.(See documentation for details)