Merge pull request #15532 from huchenlei/fix_module

Fix cls.__module__ value in extension script
This commit is contained in:
AUTOMATIC1111
2024-04-21 07:42:57 +03:00
committed by GitHub
2 changed files with 5 additions and 7 deletions

View File

@@ -9,15 +9,13 @@ loaded_scripts = {}
def load_module(path):
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
module_name, _ = os.path.splitext(os.path.basename(path))
full_module_name = "scripts." + module_name
module_spec = importlib.util.spec_from_file_location(full_module_name, path)
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
loaded_scripts[path] = module
module_name, _ = os.path.splitext(os.path.basename(path))
sys.modules["scripts." + module_name] = module
sys.modules[full_module_name] = module
return module