Implement find_spec in vendored module importers#2633
Conversation
c6c7b15 to
dcb418f
Compare
setuptools/extern/__init__.py
Outdated
| pass | ||
|
|
||
| def find_spec(self, fullname, path=None, target=None): | ||
| """Produce a registered namespace matching module spec.""" |
There was a problem hiding this comment.
| """Produce a registered namespace matching module spec.""" | |
| """Return a module spec for vendored names.""" |
There was a problem hiding this comment.
By the way, I wanted to ask if there's any particular reason for having two duplicate loaders (one in pkg_resources and another one in setuptools) — can't one import another instead of maintaining the duplicates?
There was a problem hiding this comment.
I split them in preparation for separating pkg_resources into its own package, but never succeeded at that. It would be fine for setuptools to use the loader from pkg_resources again (but not vice-versa).
jaraco
left a comment
There was a problem hiding this comment.
Couple of small questions, but overall, LGTM.
This change makes the import warning emitted by Python 3.10 disappear but implementing the hook that is supposed to replace the old import mechanism. Refs: * https://bugs.python.org/issue42134 * https://bugs.python.org/issue43540 * pypa#2632 (comment) Fixes pypa#2632 Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
e8e9a6d to
dd1453b
Compare
pkg_resources/extern/__init__.py
Outdated
| def find_spec(self, fullname, path=None, target=None): | ||
| """Return a module spec for vendored names.""" | ||
| return ( | ||
| importlib.machinery.ModuleSpec(fullname, self) |
There was a problem hiding this comment.
It looks like this could (should?) be https://docs.python.org/3/library/importlib.html#importlib.util.spec_from_loader.
Summary of changes
This change makes the import warning emitted by Python 3.10 disappear
but implementing the hook that is supposed to replace the old import
mechanism.
Refs:
Fixes #2632
Pull Request Checklist
changelog.d/.(See documentation for details)