File: use-importlib-fix.patch

package info (click to toggle)
errbot 6.2.0%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,856 kB
  • sloc: python: 11,572; makefile: 163; sh: 97
file content (116 lines) | stat: -rw-r--r-- 3,184 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
From: Sijis Aviles <sijis.aviles+github@gmail.com>
Date: Fri, 13 Jun 2025 13:50:39 -0500
Subject: fix: importlib refactor (#1733)

* fix: importlib refactor

Simplify logic and exclude cache directories.

* test: adjust and consolidate entry_point tests

* docs: add info to CHANGES

Origin: backport, https://github.com/errbotio/errbot/pull/1733
Bug-Debian: https://bugs.debian.org/1083380
Last-Update: 2026-01-06
---
 errbot/utils.py                 | 16 ++++++----------
 tests/plugin_entrypoint_test.py | 18 ------------------
 tests/utils_test.py             |  9 ++++++++-
 3 files changed, 14 insertions(+), 29 deletions(-)
 delete mode 100644 tests/plugin_entrypoint_test.py

--- a/errbot/utils.py
+++ b/errbot/utils.py
@@ -4,7 +4,6 @@
 import inspect
 import logging
 import os
-import pathlib
 import re
 import sys
 import time
@@ -199,7 +198,7 @@
 
 
 def entry_point_plugins(group):
-    paths = []
+    paths = set()
 
     eps = importlib.metadata.entry_points()
     try:
@@ -209,8 +208,6 @@
         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:
@@ -220,12 +217,11 @@
             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:
--- a/tests/plugin_entrypoint_test.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from errbot.utils import entry_point_plugins
-
-
-def test_entrypoint_paths():
-    plugins = entry_point_plugins("console_scripts")
-
-    match = False
-    for plugin in plugins:
-        if "errbot/errbot.cli" in plugin:
-            match = True
-    assert match
-
-
-def test_entrypoint_paths_empty():
-    groups = ["errbot.plugins", "errbot.backend_plugins"]
-    for entry_point_group in groups:
-        plugins = entry_point_plugins(entry_point_group)
-        assert plugins == []
--- a/tests/utils_test.py
+++ b/tests/utils_test.py
@@ -119,6 +119,13 @@
     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 == []
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,6 @@
 
 deps = [
     "webtest==3.0.0",
-    "setuptools==68.1.2",
     "flask",
     "requests==2.31.0",
     "jinja2==3.1.2",