Skip to content

Conversation

@webknjaz
Copy link
Member

@webknjaz webknjaz commented Apr 8, 2021

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

webknjaz added a commit to webknjaz/setuptools that referenced this pull request Apr 8, 2021
webknjaz added a commit to webknjaz/setuptools that referenced this pull request Apr 8, 2021
@webknjaz webknjaz force-pushed the bugfixes/2632-importlib-find_spec branch from c6c7b15 to dcb418f Compare April 8, 2021 18:38
@webknjaz webknjaz requested a review from jaraco April 8, 2021 18:39
@webknjaz webknjaz added the bug label Apr 8, 2021
pass

def find_spec(self, fullname, path=None, target=None):
"""Produce a registered namespace matching module spec."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Produce a registered namespace matching module spec."""
"""Return a module spec for vendored names."""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of small questions, but overall, LGTM.

webknjaz and others added 3 commits April 8, 2021 23:41
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>
@webknjaz webknjaz force-pushed the bugfixes/2632-importlib-find_spec branch from e8e9a6d to dd1453b Compare April 8, 2021 21:46
@webknjaz webknjaz requested a review from jaraco April 8, 2021 21:46
def find_spec(self, fullname, path=None, target=None):
"""Return a module spec for vendored names."""
return (
importlib.machinery.ModuleSpec(fullname, self)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaraco jaraco merged commit fe10ebf into pypa:main Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants