-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
pkg_resources
is deprecated, it would be nice have the docs clarify how to use click-plugins
with importlib_metadata
/ importlib.metadata
instead.
ATTENTION
Use of pkg_resources is deprecated in favor of importlib.resources, importlib.metadata and their backports (importlib_resources, importlib_metadata). Some useful APIs are also provided by packaging (e.g. requirements and version parsing). Users should refrain from new usage of pkg_resources and should work to port to importlib-based solutions.
I've replaced this:
from pkg_resources import iter_entry_points
import click
from click_plugins import with_plugins
@with_plugins(iter_entry_points('core_package.cli_plugins'))
@click.group()
def cli():
"""Commandline interface for yourpackage."""
with this:
import click
from click_plugins import with_plugins
from importlib_metadata import entry_points
@with_plugins(entry_points(group='core_package.cli_plugins'))
@click.group()
def cli():
"""Commandline interface for yourpackage."""
The above code is compatible with importlib-metadata>=3.6
wouterdb
Activity
click-plugins
ApeWorX/ape#56'pkg_resources' -> 'importlib.metadata'
geowurster commentedon Jun 9, 2025
I have switched to
importlib
in #40, but this PR comes with some major caveats.'pkg_resources' -> 'importlib.metadata'
'pkg_resources' -> 'importlib.metadata'