From e73a7e40067c3beb9aacc9d27129354446098edb Mon Sep 17 00:00:00 2001 From: storyicon Date: Mon, 1 Apr 2024 09:13:07 +0000 Subject: [PATCH] feat: ensure the indexability of dynamically imported packages Signed-off-by: storyicon --- modules/script_loading.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/script_loading.py b/modules/script_loading.py index 0d55f1932..2bd26f013 100644 --- a/modules/script_loading.py +++ b/modules/script_loading.py @@ -2,13 +2,18 @@ import os import importlib.util from modules import errors - +import sys def load_module(path): module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path) module = importlib.util.module_from_spec(module_spec) module_spec.loader.exec_module(module) - + if os.path.isfile(path): + sp = os.path.splitext(path) + module_name = sp[0] + else: + module_name = os.path.basename(path) + sys.modules[module_name] = module return module