Skip to content

Commit

Permalink
use 'scripts.' prefix for names of dynamically loaded modules
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Apr 6, 2024
1 parent badb70d commit 23c06a5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions modules/script_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 23c06a5

Please sign in to comment.