mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-03-01 16:05:59 +08:00
Merge pull request #15423 from storyicon/master
feat: ensure the indexability of dynamically imported packages
This commit is contained in:
commit
badb70da48
@ -2,13 +2,18 @@ import os
|
|||||||
import importlib.util
|
import importlib.util
|
||||||
|
|
||||||
from modules import errors
|
from modules import errors
|
||||||
|
import sys
|
||||||
|
|
||||||
def load_module(path):
|
def load_module(path):
|
||||||
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
|
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
|
||||||
module = importlib.util.module_from_spec(module_spec)
|
module = importlib.util.module_from_spec(module_spec)
|
||||||
module_spec.loader.exec_module(module)
|
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
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user