Skip to content

Commit

Permalink
Merge pull request #15423 from storyicon/master
Browse files Browse the repository at this point in the history
feat: ensure the indexability of dynamically imported packages
  • Loading branch information
AUTOMATIC1111 authored Apr 6, 2024
2 parents 447198f + e73a7e4 commit badb70d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/script_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
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


Expand Down

0 comments on commit badb70d

Please sign in to comment.