Closed jaraco closed 1 year ago
Starts to be rather cumbersome to support python>=3.7
import sys
try:
from importlib.metadata import entry_points
except ImportError:
from importlib_metadata import entry_points
if sys.version_info >= (3,10):
_entry_points = entry_points(group=namespace)
else:
try:
_entry_points = entry_points().get(namespace, [])
except AttributeError:
_entry_points = entry_points().select(group=namespace)
That's one way to do it. Other options include:
importlib_metadata
any time there's behavior from a future Python version but your application supports older Python versions.entry_points
altogether and re-implement its behavior using more fundamental interfaces (flake8 took this approach; I don't recommend it).Thanks for the feedback!
Rely on importlib_metadata >= 3.6 for Python < 3.10
Many projects just need importlib.metadata
so they have importlib-metadata; python_version < '3.8'
. Once python 3.7 gets dropped it should become simpler.
Python 3.10 still supports entry_points().select(group=namespace)
so using entry_points(group=namespace)
is not mandatory.
EntryPoints.__getitem__
by index.