use 'scripts.' prefix for names of dynamically loaded modules

This commit is contained in:
AUTOMATIC1111 2024-04-06 09:05:04 +03:00
parent badb70da48
commit 23c06a51cc
1 changed files with 10 additions and 6 deletions

View File

@ -4,16 +4,20 @@ import importlib.util
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