mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-14 08:16:15 +01: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:
commit
43f07f90c4
@ -259,7 +259,12 @@ class MainCommand(Command):
|
|||||||
def load_commands(self):
|
def load_commands(self):
|
||||||
for module_prefix, module_path in self.MODULES:
|
for module_prefix, module_path in self.MODULES:
|
||||||
module_path = os.path.expanduser(module_path)
|
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}"
|
full_name = f"{module_prefix}.{module_name}"
|
||||||
spec = loader.find_spec(full_name)
|
spec = loader.find_spec(full_name)
|
||||||
mod = importlib.util.module_from_spec(spec)
|
mod = importlib.util.module_from_spec(spec)
|
||||||
|
Loading…
Reference in New Issue
Block a user