Catch `SystemExit` during module discovery
Hit if directory in TMT_PLUGINS contains 'setup.py' which is executed
and fails due missing arguments (usually it is 'install' which happens
during e.g `pip install <dir>`).
User should change the directory structure and point TMT_PLUGINS
elsewhere.
@@ -67,7 +67,8 @@ def import_(module: str, path: Optional[str] = None) -> None:
try:
importlib.import_module(module)
log.debug(f"Successfully imported the '{module}' module.")
- except ImportError as error:
+ except (ImportError, SystemExit) as error:
+ # setup.py when executed during import raises SystemExit
raise SystemExit(
f"Failed to import the '{module}' module" +
(f" from '{path}'." if path else ".") + f"\n({error})")
