Fix loading extensions with "-" in the name (closes #5557)

This commit is contained in:
oobabooga 2024-02-25 09:24:52 -08:00
parent 0f68c6fb5b
commit d34126255d

View File

@ -1,3 +1,4 @@
import importlib
import traceback import traceback
from functools import partial from functools import partial
from inspect import signature from inspect import signature
@ -33,13 +34,11 @@ def load_extensions():
logger.info(f'Loading the extension "{name}"') logger.info(f'Loading the extension "{name}"')
try: try:
try: try:
exec(f"import extensions.{name}.script") extension = importlib.import_module(f"extensions.{name}.script")
except ModuleNotFoundError: except ModuleNotFoundError:
logger.error(f"Could not import the requirements for '{name}'. Make sure to install the requirements for the extension.\n\nLinux / Mac:\n\npip install -r extensions/{name}/requirements.txt --upgrade\n\nWindows:\n\npip install -r extensions\\{name}\\requirements.txt --upgrade\n\nIf you used the one-click installer, paste the command above in the terminal window opened after launching the cmd script for your OS.") logger.error(f"Could not import the requirements for '{name}'. Make sure to install the requirements for the extension.\n\nLinux / Mac:\n\npip install -r extensions/{name}/requirements.txt --upgrade\n\nWindows:\n\npip install -r extensions\\{name}\\requirements.txt --upgrade\n\nIf you used the one-click installer, paste the command above in the terminal window opened after launching the cmd script for your OS.")
raise raise
extension = getattr(extensions, name).script
# Only run setup() and apply settings from settings.yaml once # Only run setup() and apply settings from settings.yaml once
if extension not in setup_called: if extension not in setup_called:
apply_settings(extension, name) apply_settings(extension, name)