1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-09-06 13:18:42 +02:00

Merge pull request #1293 from dmach/cli-fix-loading-plugins

commandline: Append plugin dirs to sys.path to allow loading modules installed next to the plugins
This commit is contained in:
2023-04-11 13:41:11 +02:00
committed by GitHub

View File

@@ -259,7 +259,12 @@ class MainCommand(Command):
def load_commands(self):
for module_prefix, module_path in self.MODULES:
module_path = os.path.expanduser(module_path)
for loader, module_name, _ in pkgutil.walk_packages(path=[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.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)