Skip to content

Commit

Permalink
fix/entrypoint_loading
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JarbasAl committed Jan 30, 2023
1 parent 1012f3f commit 9747aab
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ovos_plugin_manager/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,25 @@ def find_plugins(plug_type=None):
else:
plugs = plug_type
for plug in plugs:
for entry_point in pkg_resources.iter_entry_points(plug):
for entry_point in _iter_entrypoints(plug):
try:
entrypoints[entry_point.name] = entry_point.load()
LOG.debug(f"Loaded plugin entry point {entry_point.name}")
except Exception as e:
LOG.exception(f"Failed to load plugin entry point {entry_point}")
return entrypoints


def _iter_entrypoints(plug_type):
try:
from importlib_metadata import entry_points
for entry_point in entry_points(group=plug_type):
yield entry_point
except ImportError:
for entry_point in pkg_resources.iter_entry_points(plug_type):
yield entry_point


def load_plugin(plug_name, plug_type=None):
"""Load a specific plugin from a specific plugin type.
Expand Down

0 comments on commit 9747aab

Please sign in to comment.