2019-08-20 15:01:34 +00:00
|
|
|
# -*- mode: python -*-
|
|
|
|
import importlib
|
|
|
|
import os
|
2024-02-09 22:06:03 +00:00
|
|
|
import importlib_metadata
|
2019-08-20 15:01:34 +00:00
|
|
|
|
|
|
|
block_cipher = None
|
|
|
|
|
|
|
|
datas = [("./tutor/templates", "./tutor/templates")]
|
|
|
|
hidden_imports = []
|
|
|
|
|
|
|
|
# Auto-discover plugins and include patches & templates folders
|
2022-04-24 12:59:42 +00:00
|
|
|
for entrypoint_version in ["tutor.plugin.v0", "tutor.plugin.v1"]:
|
2024-01-11 13:20:04 +00:00
|
|
|
for entrypoint in importlib_metadata.entry_points(group=entrypoint_version):
|
2022-04-24 12:59:42 +00:00
|
|
|
plugin_name = entrypoint.name
|
|
|
|
try:
|
2024-01-11 13:20:04 +00:00
|
|
|
plugin = importlib.import_module(entrypoint.value)
|
2022-04-24 12:59:42 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(f"ERROR Failed to load plugin {plugin_name}: {e}")
|
|
|
|
continue
|
|
|
|
plugin_root = os.path.dirname(plugin.__file__)
|
|
|
|
plugin_root_module_name = os.path.basename(plugin_root)
|
2024-02-09 22:06:03 +00:00
|
|
|
hidden_imports.append(entrypoint.module)
|
2022-04-24 12:59:42 +00:00
|
|
|
for folder in ["patches", "templates"]:
|
|
|
|
path = os.path.join(plugin_root, folder)
|
|
|
|
if os.path.exists(path):
|
|
|
|
datas.append((path, os.path.join(plugin_root_module_name, folder)))
|
2020-09-17 10:53:14 +00:00
|
|
|
# Fix license import: if we don't declare some modules, pyinstaller does not find them
|
2019-12-25 00:09:53 +00:00
|
|
|
hidden_imports.append("tutorlts.__about__")
|
|
|
|
hidden_imports.append("Crypto.Cipher.AES")
|
|
|
|
hidden_imports.append("Crypto.Cipher.PKCS1_OAEP")
|
2019-12-25 00:16:17 +00:00
|
|
|
hidden_imports.append("Crypto.Hash.SHA256")
|
2019-12-25 00:09:53 +00:00
|
|
|
hidden_imports.append("Crypto.PublicKey.RSA")
|
|
|
|
hidden_imports.append("Crypto.Random")
|
|
|
|
hidden_imports.append("Crypto.Signature.PKCS1_v1_5")
|
Improve job running in local and k8s
Running jobs was previously done with "exec". This was because it
allowed us to avoid copying too much container specification information
from the docker-compose/deployments files to the jobs files. However,
this was limiting:
- In order to run a job, the corresponding container had to be running.
This was particularly painful in Kubernetes, where containers are
crashing as long as migrations are not correctly run.
- Containers in which we need to run jobs needed to be present in the
docker-compose/deployments files. This is unnecessary, for example when
mysql is disabled, or in the case of the certbot container.
Now, we create dedicated jobs files, both for local and k8s deployment.
This introduces a little redundancy, but not too much. Note that
dependent containers are not listed in the docker-compose.jobs.yml file,
so an actual platform is still supposed to be running when we launch the
jobs.
This also introduces a subtle change: now, jobs go through the container
entrypoint prior to running. This is probably a good thing, as it will
avoid forgetting about incorrect environment variables.
In k8s, we find ourselves interacting way too much with the kubectl
utility. Parsing output from the CLI is a pain. So we need to switch to
the native kubernetes client library.
2020-03-25 17:47:36 +00:00
|
|
|
hidden_imports.append("kubernetes")
|
2019-12-25 00:09:53 +00:00
|
|
|
hidden_imports.append("uuid")
|
|
|
|
|
2019-08-20 15:01:34 +00:00
|
|
|
|
|
|
|
# The following was initially generated with:
|
|
|
|
# pyinstaller --onefile --name=tutor --add-data=./tutor/templates:./tutor/templates ./bin/main.py
|
|
|
|
|
|
|
|
a = Analysis(
|
|
|
|
["bin/main.py"],
|
|
|
|
pathex=[os.path.abspath(".")],
|
|
|
|
binaries=[],
|
|
|
|
datas=datas,
|
|
|
|
hiddenimports=hidden_imports,
|
|
|
|
hookspath=[],
|
|
|
|
runtime_hooks=[],
|
|
|
|
excludes=[],
|
|
|
|
win_no_prefer_redirects=False,
|
|
|
|
win_private_assemblies=False,
|
|
|
|
cipher=block_cipher,
|
|
|
|
noarchive=False,
|
|
|
|
)
|
|
|
|
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
|
|
|
exe = EXE(
|
|
|
|
pyz,
|
|
|
|
a.scripts,
|
|
|
|
a.binaries,
|
|
|
|
a.zipfiles,
|
|
|
|
a.datas,
|
|
|
|
[],
|
|
|
|
name="tutor",
|
|
|
|
debug=False,
|
|
|
|
bootloader_ignore_signals=False,
|
|
|
|
strip=False,
|
|
|
|
upx=True,
|
|
|
|
runtime_tmpdir=None,
|
|
|
|
console=True,
|
|
|
|
)
|