Skip to content

Commit

Permalink
refactor: detecting entry point plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
sijis committed Jan 23, 2023
1 parent ba33d44 commit 6d858ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 5 additions & 2 deletions errbot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import inspect
import logging
import os
import pathlib
import re
import sys
import time
Expand Down Expand Up @@ -206,8 +207,10 @@ def collect_roots(base_paths: List, file_sig: str = "*.plug") -> List:
def entry_point_plugins(group):
paths = []
for entry_point in entry_points().get(group, []):
lib_paths = find_spec(entry_point.module).submodule_search_locations
paths.extend(lib_paths)
entry_point_path = find_spec(entry_point.module).origin
lib_directory = pathlib.Path(entry_point_path).parent
if lib_directory:
paths.append(str(lib_directory))
return paths


Expand Down
14 changes: 14 additions & 0 deletions tests/plugin_entrypoint_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from errbot.utils import entry_point_plugins


def test_entrypoint_paths():
plugins = entry_point_plugins("console_scripts")

matches = []
for plugin in plugins:
if 'errbot' in plugin:
break
else:
assert False

assert True

0 comments on commit 6d858ae

Please sign in to comment.