From 9620447a4d9026e37f6b768ad46ed9a97e79cda5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9gis=20Behmo?= <regis@behmo.com>
Date: Wed, 25 Dec 2019 01:09:53 +0100
Subject: [PATCH] Add the lts plugin to the tutor binary

---
 Makefile                 |  8 ++++----
 bin/main.py              |  4 ++--
 docs/index.rst           |  2 ++
 requirements/plugins.txt |  1 +
 tutor.spec               | 10 ++++++++++
 5 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 3deaa3c..18b0158 100644
--- a/Makefile
+++ b/Makefile
@@ -72,16 +72,16 @@ ci-install-python-requirements: ## Install requirements
 ci-install-plugins: ci-install-python-requirements ## Install alll supported plugins
 	pip3 install -r requirements/plugins.txt
 
-ci-bundle: ## Create bundle and run basic tests
-	$(MAKE) bundle
-	mkdir -p releases/
+ci-bundle: bundle ## Create bundle and run basic tests
 	./dist/tutor --version
 	./dist/tutor config printroot
 	yes "" | ./dist/tutor config save --interactive
 	./dist/tutor config save
-	./dist/tutor plugins enable discovery ecommerce minio notes xqueue
+	./dist/tutor plugins enable discovery ecommerce figures lts minio notes xqueue
+	./dist/tutor lts --help
 
 ./releases/github-release: ## Download github-release binary
+	mkdir -p releases/
 	cd releases/ \
 		&& curl -sSL -o ./github-release.tar.bz2 "https://github.com/aktau/github-release/releases/download/v0.7.2/$(shell uname -s | tr "[:upper:]" "[:lower:]")-amd64-github-release.tar.bz2" \
 		&& bzip2 -d -f ./github-release.tar.bz2 \
diff --git a/bin/main.py b/bin/main.py
index 0c6d3b9..60d9c38 100755
--- a/bin/main.py
+++ b/bin/main.py
@@ -1,11 +1,10 @@
 #!/usr/bin/env python3
 import importlib
 
-from tutor.commands.cli import main
 from tutor.plugins import Plugins
 
 # Manually install plugins (this is for creating the bundle)
-for plugin in ["discovery", "ecommerce", "figures", "minio", "notes", "xqueue"]:
+for plugin in ["discovery", "ecommerce", "figures", "lts", "minio", "notes", "xqueue"]:
     try:
         module = importlib.import_module("tutor{}.plugin".format(plugin))
     except ImportError:
@@ -13,4 +12,5 @@ for plugin in ["discovery", "ecommerce", "figures", "minio", "notes", "xqueue"]:
     else:
         Plugins.EXTRA_INSTALLED[plugin] = module
 
+from tutor.commands.cli import main
 main()
diff --git a/docs/index.rst b/docs/index.rst
index 7b8a557..f4e7213 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -52,4 +52,6 @@ This work is licensed under the terms of the `GNU Affero General Public License
 
 The AGPL license covers the Tutor code, including the Dockerfiles, but not the content of the Docker images which can be downloaded from https://hub.docker.com. Software other than Tutor provided with the docker images retain their original license.
 
+The Tutor plugin system is licensed under the terms of the `Apache License, Version 2.0 <https://opensource.org/licenses/Apache-2.0>`__.
+
 The :ref:`Tutor Web UI <webui>` depends on the `Gotty <https://github.com/yudai/gotty/>`_ binary, which is provided under the terms of the `MIT license <https://github.com/yudai/gotty/blob/master/LICENSE>`_.
diff --git a/requirements/plugins.txt b/requirements/plugins.txt
index 7237b94..d3c079c 100644
--- a/requirements/plugins.txt
+++ b/requirements/plugins.txt
@@ -1,6 +1,7 @@
 tutor-discovery
 tutor-ecommerce
 tutor-figures
+tutor-lts
 tutor-minio
 tutor-notes
 tutor-xqueue
\ No newline at end of file
diff --git a/tutor.spec b/tutor.spec
index d5a0dff..aef3b3f 100644
--- a/tutor.spec
+++ b/tutor.spec
@@ -19,6 +19,16 @@ for entrypoint in pkg_resources.iter_entry_points("tutor.plugin.v0"):
         path = os.path.join(plugin_root, folder)
         if os.path.exists(path):
             datas.append((path, os.path.join(plugin_root_module_name, folder)))
+# Fix lts import: if we don't declare some modules, pyinstaller does not find them
+hidden_imports.append("tutorlts.__about__")
+hidden_imports.append("Crypto.Cipher.AES")
+hidden_imports.append("Crypto.Cipher.PKCS1_OAEP")
+hidden_imports.append("Crypto.Hash")
+hidden_imports.append("Crypto.PublicKey.RSA")
+hidden_imports.append("Crypto.Random")
+hidden_imports.append("Crypto.Signature.PKCS1_v1_5")
+hidden_imports.append("uuid")
+
 
 # The following was initially generated with:
 # pyinstaller --onefile --name=tutor --add-data=./tutor/templates:./tutor/templates ./bin/main.py
-- 
GitLab