From 23c06a51ccc54d76db465f8f66a5dcb0f7ca33e5 Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Sat, 6 Apr 2024 09:05:04 +0300 Subject: [PATCH] use 'scripts.' prefix for names of dynamically loaded modules --- modules/script_loading.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/script_loading.py b/modules/script_loading.py index 2bd26f013fe..17f658b1544 100644 --- a/modules/script_loading.py +++ b/modules/script_loading.py @@ -4,16 +4,20 @@ from modules import errors import sys + +loaded_scripts = {} + + 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 + + loaded_scripts[path] = module + + module_name, _ = os.path.splitext(os.path.basename(path)) + sys.modules["scripts." + module_name] = module + return module