Skip to content

Commit 74c82b8

Browse files
authored
fix/entrypoint_loading (#117)
this avoids issues with requirement versions mismatches in skills, this should be handled at install time not runtime solution taken from: click-contrib/click-plugins#31
1 parent ccb9ad3 commit 74c82b8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ovos_plugin_manager/utils/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,25 @@ def find_plugins(plug_type=None):
8282
else:
8383
plugs = plug_type
8484
for plug in plugs:
85-
for entry_point in pkg_resources.iter_entry_points(plug):
85+
for entry_point in _iter_entrypoints(plug):
8686
try:
8787
entrypoints[entry_point.name] = entry_point.load()
88+
LOG.debug(f"Loaded plugin entry point {entry_point.name}")
8889
except Exception as e:
8990
LOG.exception(f"Failed to load plugin entry point {entry_point}")
9091
return entrypoints
9192

9293

94+
def _iter_entrypoints(plug_type):
95+
try:
96+
from importlib_metadata import entry_points
97+
for entry_point in entry_points(group=plug_type):
98+
yield entry_point
99+
except ImportError:
100+
for entry_point in pkg_resources.iter_entry_points(plug_type):
101+
yield entry_point
102+
103+
93104
def load_plugin(plug_name, plug_type=None):
94105
"""Load a specific plugin from a specific plugin type.
95106

0 commit comments

Comments
 (0)