Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fixes:
- fix: add extra_plugin_dir support to FullStackTest (#1726)
- fix: add missing py 3.13 in tox (#1731)
- fix: add filter to tar extract (#1730)
- refactor: use importlib to find plugins in entry_points (#1669)
- refactor: use importlib to find plugins in entry_points (#1669, #1733)


v6.2.0 (2024-01-01)
Expand Down
16 changes: 6 additions & 10 deletions errbot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import inspect
import logging
import os
import pathlib
import re
import sys
import time
Expand Down Expand Up @@ -199,7 +198,7 @@ def collect_roots(base_paths: List, file_sig: str = "*.plug") -> List:


def entry_point_plugins(group):
paths = []
paths = set()

eps = importlib.metadata.entry_points()
try:
Expand All @@ -209,8 +208,6 @@ def entry_point_plugins(group):
entry_points = eps.get(group, ())

for entry_point in entry_points:
module_name = entry_point.module
file_name = module_name.replace(".", "/") + ".py"
try:
files = entry_point.dist.files
except AttributeError:
Expand All @@ -220,12 +217,11 @@ def entry_point_plugins(group):
except importlib.metadata.PackageNotFoundError:
# entrypoint is not a distribution, so let's skip looking for files
continue

for f in files:
if file_name == str(f):
parent = str(pathlib.Path(f).resolve().parent)
paths.append(f"{parent}/{module_name}")
return paths
for file in files:
if "__pycache__" not in file.parts:
parent = file.locate().absolute().resolve().parent
paths.add(str(parent))
return list(paths)


def global_restart() -> None:
Expand Down
18 changes: 0 additions & 18 deletions tests/plugin_entrypoint_test.py

This file was deleted.

9 changes: 8 additions & 1 deletion tests/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ def test_entry_point_plugins_valid_groups():
results = entry_point_plugins("console_scripts")
match = False
for result in results:
if result.endswith("errbot/errbot.cli"):
if "errbot" in result:
match = True
assert match


def test_entry_point_paths_empty():
groups = ["errbot.plugins", "errbot.backend_plugins"]
for entry_point_group in groups:
plugins = entry_point_plugins(entry_point_group)
assert plugins == []