1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 22:56:15 +01:00

commandline: Append plugin dirs to sys.path to allow loading modules installed next to the plugins

This commit is contained in:
Daniel Mach 2023-04-05 15:53:17 +02:00
parent 9e0d7783d6
commit 497f4db18b

View File

@ -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)