Skip to content

fix/entrypoint_loading #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add some test case for this? Maybe a test skill branch we install that specifies an exact OPM version older than this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets do this in another PR before the next stable release, i want to get this fix out asap as this makes it really painful to use some plugins

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