Skip to content
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 should be replaced with importlib.metadata #11

Open
dgw opened this issue May 28, 2024 · 0 comments
Open

pkg_resources should be replaced with importlib.metadata #11

dgw opened this issue May 28, 2024 · 0 comments

Comments

@dgw
Copy link
Member

dgw commented May 28, 2024

Sopel itself did this some time ago (sopel-irc/sopel#2261) for 8.0. The setuptools project discourages new usage of its pkg_resources library, and I should also note that a fresh installation of Python* raised an error when trying to load this plugin because it couldn't find pkg_resources; the setuptools package wasn't installed by default, and the plugin doesn't declare it as a runtime dependency.

Since using pkg_resources is discouraged, I'm opening an issue reminding us that a migration needs to happen instead of just making a quick PR to add setuptools as a runtime requirement.

Like sopel itself, this plugin should probably make use of the importlib_metadata backport package instead of try/except around different ways of calling importlib.metadata.entry_points(). The simple approach (subscripting as entry_points()['name'] or using entry_points().get('name)) worked up until Python 3.12, which now always returns an EntryPoints object instead of a dict-like.

The most natural time for this migration to happen, IMO, would be in the first release of sopel-help that no longer supports Sopel 7.x—meaning it would only need to make sure the importlib-based solution works on Python 3.8+ and not all the way back to py2.7.


* — In this specific case I was curiously testing sopel's master branch on Windows after recent chat in our IRC channel, but *nix Python environments that don't have setuptools unless it's manually installed from the system package manager or pip also exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant