|
|
|
@ -27,6 +27,7 @@ import pkgutil |
|
|
|
import importlib.util |
|
|
|
import importlib.util |
|
|
|
import time |
|
|
|
import time |
|
|
|
import threading |
|
|
|
import threading |
|
|
|
|
|
|
|
import sys |
|
|
|
from typing import NamedTuple, Any, Union, TYPE_CHECKING, Optional |
|
|
|
from typing import NamedTuple, Any, Union, TYPE_CHECKING, Optional |
|
|
|
|
|
|
|
|
|
|
|
from .i18n import _ |
|
|
|
from .i18n import _ |
|
|
|
@ -73,6 +74,9 @@ class Plugins(DaemonThread): |
|
|
|
raise Exception(f"Error pre-loading {full_name}: no spec") |
|
|
|
raise Exception(f"Error pre-loading {full_name}: no spec") |
|
|
|
try: |
|
|
|
try: |
|
|
|
module = importlib.util.module_from_spec(spec) |
|
|
|
module = importlib.util.module_from_spec(spec) |
|
|
|
|
|
|
|
# sys.modules needs to be modified for relative imports to work |
|
|
|
|
|
|
|
# see https://stackoverflow.com/a/50395128 |
|
|
|
|
|
|
|
sys.modules[spec.name] = module |
|
|
|
spec.loader.exec_module(module) |
|
|
|
spec.loader.exec_module(module) |
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
raise Exception(f"Error pre-loading {full_name}: {repr(e)}") from e |
|
|
|
raise Exception(f"Error pre-loading {full_name}: {repr(e)}") from e |
|
|
|
|