-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
core: replace pkg_resources
with importlib.metadata
#2261
Conversation
Needs a backport package until we no longer support Python 3.7; stdlib gained `importlib.metadata` in Python 3.8. I should note that installing with `-r dev-requirements.txt` will always (currently) install the `importlib_metadata` backport because of Sphinx.
Unfortunately this one is *not* yet part of the stdlib in any Python release, but there's no point in removing only *most* uses of the older `pkg_resources` library. Gotta do them *all*.
Adapted the `get_meta_description()` for `EntryPointPlugin` to return the expected format. Could alternatively change the expectation of `test_get_label_entrypoint()`.
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.
Impressive work, having to deal with setuptools, metadata, and backport packages for Python version up to 3.9 is no small feat. Well done!
I don't approve yet because of one comment, however, it's only for documentation.
As the Python packaging docs say, entry points are now a PyPA-defined interoperability specification not confined to packages built using `setuptools`, and we should update our docs to reflect that. See https://packaging.python.org/en/latest/specifications/entry-points/
@Exirel I went a bit ham on updating the docs instead of just tweaking the one |
It's not a "setuptools entry point"; it's an "entry point group".
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 clearly not going to nitpick at grammar, this looks pretty good to me.
Followed up with #2268, since the |
Description
Tin. Performance of
pkg_resources
can be quite slow (just search all of GitHub issues for "pkg_resources slow"); its use is discouraged by thesetuptools
project itself, in favor of the newer modules such asimportlib.metadata
.Needs a backport package until we no longer support Python 3.9. stdlib gained
importlib.metadata
in Python 3.8, but the ability to "select" inentry_points()
won't be added until Python 3.10. I don't mind this, because it takes an implied dependency (setuptools
was required to install Sopel but not listed inrequirements.txt
) and makes it explicit until we can use the stdlib version. My requirement specifier gives the minimum version of theimportlib_metadata
backport that supports selectors.I didn't see a direct equivalent to
pkg_resources.parse_version()
inimportlib.metadata
; looking at a couple other projects that have already made the move away frompkg_resources
told me thatpackaging.version.parse()
is the way to go.Checklist
make qa
(runsmake quality
andmake test
)sopel-dns
on my local (-e .
) SopelTest instance with no issues.Notes
We devs/hackers have been installing
importlib_metadata
for a while without thinking about it, because Sphinx explicitly requires it for install on py<3.10.