Skip to content

Commit

Permalink
importlib_metadata removed deprecated entry point interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
woutdenolf committed Oct 3, 2022
1 parent 6ae9fac commit b998a72
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions kombu/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from functools import wraps

try:
from importlib import metadata as importlib_metadata
from importlib.metadata import entry_points
except ImportError:
# TODO: Remove this when we drop support for Python 3.7
import importlib_metadata
from importlib_metadata import entry_points

from io import UnsupportedOperation

Expand Down Expand Up @@ -80,12 +80,16 @@ def detect_environment():
def entrypoints(namespace):
"""Return setuptools entrypoints for namespace."""
if sys.version_info >= (3,10):
entry_points = importlib_metadata.entry_points(group=namespace)
_entry_points = entry_points(group=namespace)
else:
entry_points = importlib_metadata.entry_points().get(namespace, [])
try:
_entry_points = entry_points().get(namespace, [])
except AttributeError:
_entry_points = entry_points().select(namespace, [])

return (
(ep, ep.load())
for ep in entry_points
for ep in _entry_points
)


Expand Down

0 comments on commit b998a72

Please sign in to comment.