From 497f4db18b286348d1f05250e5f26e5ff173dc76 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 5 Apr 2023 15:53:17 +0200 Subject: [PATCH 1/2] commandline: Append plugin dirs to sys.path to allow loading modules installed next to the plugins --- osc/commandline.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osc/commandline.py b/osc/commandline.py index f0c2b367..1754390d 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -259,6 +259,11 @@ class MainCommand(Command): def load_commands(self): for module_prefix, module_path in self.MODULES: module_path = os.path.expanduser(module_path) + + # some plugins have their modules installed next to them instead of site-packages + if module_path not in sys.path: + sys.path.append(module_path) + for loader, module_name, _ in pkgutil.walk_packages(path=[module_path]): full_name = f"{module_prefix}.{module_name}" spec = loader.find_spec(full_name) From baca98abbb55aaa5c809fd1957142286f9cc234a Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 5 Apr 2023 15:54:20 +0200 Subject: [PATCH 2/2] commandline: Do not recurse into subdirs when loading plugins --- osc/commandline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osc/commandline.py b/osc/commandline.py index 1754390d..63941e13 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -264,7 +264,7 @@ class MainCommand(Command): if module_path not in sys.path: sys.path.append(module_path) - for loader, module_name, _ in pkgutil.walk_packages(path=[module_path]): + for loader, module_name, _ in pkgutil.iter_modules(path=[module_path]): full_name = f"{module_prefix}.{module_name}" spec = loader.find_spec(full_name) mod = importlib.util.module_from_spec(spec)