6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 06:07:56 +00:00

fix: v1 plugins in binary bundle

This commit is contained in:
Régis Behmo 2022-04-24 14:59:42 +02:00
parent e15c107570
commit 51e93941e0

View File

@ -9,20 +9,21 @@ datas = [("./tutor/templates", "./tutor/templates")]
hidden_imports = [] hidden_imports = []
# Auto-discover plugins and include patches & templates folders # Auto-discover plugins and include patches & templates folders
for entrypoint in pkg_resources.iter_entry_points("tutor.plugin.v0"): for entrypoint_version in ["tutor.plugin.v0", "tutor.plugin.v1"]:
plugin_name = entrypoint.name for entrypoint in pkg_resources.iter_entry_points(entrypoint_version):
try: plugin_name = entrypoint.name
plugin = entrypoint.load() try:
except Exception as e: plugin = entrypoint.load()
print(f"ERROR Failed to load plugin {plugin_name}: {e}") except Exception as e:
continue print(f"ERROR Failed to load plugin {plugin_name}: {e}")
plugin_root = os.path.dirname(plugin.__file__) continue
plugin_root_module_name = os.path.basename(plugin_root) plugin_root = os.path.dirname(plugin.__file__)
hidden_imports.append(entrypoint.module_name) plugin_root_module_name = os.path.basename(plugin_root)
for folder in ["patches", "templates"]: hidden_imports.append(entrypoint.module_name)
path = os.path.join(plugin_root, folder) for folder in ["patches", "templates"]:
if os.path.exists(path): path = os.path.join(plugin_root, folder)
datas.append((path, os.path.join(plugin_root_module_name, folder))) if os.path.exists(path):
datas.append((path, os.path.join(plugin_root_module_name, folder)))
# Fix license import: if we don't declare some modules, pyinstaller does not find them # Fix license import: if we don't declare some modules, pyinstaller does not find them
hidden_imports.append("tutorlts.__about__") hidden_imports.append("tutorlts.__about__")
hidden_imports.append("Crypto.Cipher.AES") hidden_imports.append("Crypto.Cipher.AES")