Skip to content

Commit a3b850f

Browse files
fix importlib_metadata issue for early versions (geopython#1242)
1 parent e06ff73 commit a3b850f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pygeoapi/__init__.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,20 @@ def _find_plugins():
5050
"""
5151

5252
def decorator(click_group):
53-
for entry_point in entry_points(group="pygeoapi"):
53+
try:
54+
found_entrypoints = entry_points(group="pygeoapi")
55+
except TypeError:
56+
# earlier versions of importlib_metadata did not have the
57+
# `group` kwarg. More detail:
58+
#
59+
# https://github.com/geopython/pygeoapi/issues/1241#issuecomment-1536128897 # noqa: E501
60+
for group, entries in entry_points().items():
61+
if group == "pygeoapi":
62+
found_entrypoints = entries
63+
break
64+
else:
65+
found_entrypoints = []
66+
for entry_point in found_entrypoints:
5467
try:
5568
click_group.add_command(entry_point.load())
5669
except Exception as err:

0 commit comments

Comments
 (0)