Debian Codegraph @

debian/patches/use-importlib-fix.patch

raw
1 From: Sijis Aviles <[email protected]>
2 Date: Fri, 13 Jun 2025 13:50:39 -0500
3 Subject: fix: importlib refactor (#1733)
4
5 * fix: importlib refactor
6
7 Simplify logic and exclude cache directories.
8
9 * test: adjust and consolidate entry_point tests
10
11 * docs: add info to CHANGES
12
13 Origin: backport, https://github.com/errbotio/errbot/pull/1733
14 Bug-Debian: https://bugs.debian.org/1083380
15 Last-Update: 2026-01-06
16 ---
17 errbot/utils.py | 16 ++++++----------
18 tests/plugin_entrypoint_test.py | 18 ------------------
19 tests/utils_test.py | 9 ++++++++-
20 3 files changed, 14 insertions(+), 29 deletions(-)
21 delete mode 100644 tests/plugin_entrypoint_test.py
22
23 --- a/errbot/utils.py
24 +++ b/errbot/utils.py
25 @@ -4,7 +4,6 @@
26 import inspect
27 import logging
28 import os
29 -import pathlib
30 import re
31 import sys
32 import time
33 @@ -199,7 +198,7 @@
34
35
36 def entry_point_plugins(group):
37 - paths = []
38 + paths = set()
39
40 eps = importlib.metadata.entry_points()
41 try:
42 @@ -209,8 +208,6 @@
43 entry_points = eps.get(group, ())
44
45 for entry_point in entry_points:
46 - module_name = entry_point.module
47 - file_name = module_name.replace(".", "/") + ".py"
48 try:
49 files = entry_point.dist.files
50 except AttributeError:
51 @@ -220,12 +217,11 @@
52 except importlib.metadata.PackageNotFoundError:
53 # entrypoint is not a distribution, so let's skip looking for files
54 continue
55 -
56 - for f in files:
57 - if file_name == str(f):
58 - parent = str(pathlib.Path(f).resolve().parent)
59 - paths.append(f"{parent}/{module_name}")
60 - return paths
61 + for file in files:
62 + if "__pycache__" not in file.parts:
63 + parent = file.locate().absolute().resolve().parent
64 + paths.add(str(parent))
65 + return list(paths)
66
67
68 def global_restart() -> None:
69 --- a/tests/plugin_entrypoint_test.py
70 +++ /dev/null
71 @@ -1,18 +0,0 @@
72 -from errbot.utils import entry_point_plugins
73 -
74 -
75 -def test_entrypoint_paths():
76 - plugins = entry_point_plugins("console_scripts")
77 -
78 - match = False
79 - for plugin in plugins:
80 - if "errbot/errbot.cli" in plugin:
81 - match = True
82 - assert match
83 -
84 -
85 -def test_entrypoint_paths_empty():
86 - groups = ["errbot.plugins", "errbot.backend_plugins"]
87 - for entry_point_group in groups:
88 - plugins = entry_point_plugins(entry_point_group)
89 - assert plugins == []
90 --- a/tests/utils_test.py
91 +++ b/tests/utils_test.py
92 @@ -119,6 +119,13 @@
93 results = entry_point_plugins("console_scripts")
94 match = False
95 for result in results:
96 - if result.endswith("errbot/errbot.cli"):
97 + if "errbot" in result:
98 match = True
99 assert match
100 +
101 +
102 +def test_entry_point_paths_empty():
103 + groups = ["errbot.plugins", "errbot.backend_plugins"]
104 + for entry_point_group in groups:
105 + plugins = entry_point_plugins(entry_point_group)
106 + assert plugins == []
107 --- a/setup.py
108 +++ b/setup.py
109 @@ -28,7 +28,6 @@
110
111 deps = [
112 "webtest==3.0.0",
113 - "setuptools==68.1.2",
114 "flask",
115 "requests==2.31.0",
116 "jinja2==3.1.2",