Add all plugins (with data) to binary bundle

All existing plugins are added to the binary bundle, in their latest
version, so that users don't need to pip install tutor.

Also, the tutor MANIFEST.in file was removed to simplify the management
of package data.

Close #242.
This commit is contained in:
Régis Behmo 2019-08-20 17:01:34 +02:00
parent 4d7ec486f3
commit be1ff08917
9 changed files with 83 additions and 31 deletions

1
.gitignore vendored
View File

@ -4,7 +4,6 @@ TODO
__pycache__
*.egg-info/
/tutor.spec
/build/
/dist/
/releases/

View File

@ -2,6 +2,10 @@
Note: Breaking changes between versions are indicated by "💥".
## Latest
- [Bugfix/Improvement] Add all plugins (with data) into binary bundle (#242)
## 3.6.2 (2019-08-07)
- [Bugfix] Fix missing templates in bundled plugins

View File

@ -1 +0,0 @@
recursive-include tutor/templates *

View File

@ -43,7 +43,7 @@ format: ## Format code automatically
###### Deployment
bundle: ## Bundle the tutor package in a single "dist/tutor" executable
pyinstaller --onefile --name=tutor --add-data=./tutor/templates:./tutor/templates ./bin/main.py
pyinstaller tutor.spec
dist/tutor:
$(MAKE) bundle

View File

@ -1,14 +1,16 @@
#!/usr/bin/env python3
import importlib
from tutor.commands.cli import main
# Manually adding plugins to bundle
from tutor.plugins import Plugins
import tutorminio.plugin
import tutornotes.plugin
import tutorxqueue.plugin
Plugins.EXTRA_INSTALLED["minio"] = tutorminio.plugin
Plugins.EXTRA_INSTALLED["notes"] = tutornotes.plugin
Plugins.EXTRA_INSTALLED["xqueue"] = tutorxqueue.plugin
# Manually install plugins (this is for creating the bundle)
for plugin in ["discovery", "ecommerce", "figures", "minio", "notes", "xqueue"]:
try:
module = importlib.import_module("tutor{}.plugin".format(plugin))
except ImportError:
pass
else:
Plugins.EXTRA_INSTALLED[plugin] = module
main()

View File

@ -32,13 +32,8 @@ The latest binaries can be downloaded from https://github.com/overhangio/tutor/r
This is the recommended installation method for most people.
Cloud deployment
----------------
Tutor can be launched on Amazon Web Services very quickly with the `official Tutor AMI <https://aws.amazon.com/marketplace/pp/B07PV3TB8X>`_. Shell access is not even required, as all configuration will happen through the Tutor web user interface. This is a commercial offer priced at $50/month ($500/year) that was created to support the development of Tutor.
Installing from source
----------------------
From source
-----------
If you would like to inspect the Tutor source code, you are most welcome to install Tutor from `Pypi <https://pypi.org/project/tutor-openedx/>`_ or directly from `the Github repository <https://github.com/overhangio/tutor>`_. You will need python >= 3.5 and the libyaml development headers. On Ubuntu, these requirements can be installed by running::
@ -54,6 +49,11 @@ Installing from a local clone of the repository::
cd tutor
pip install -e .
Cloud deployment
----------------
Tutor can be launched on Amazon Web Services very quickly with the `official Tutor AMI <https://aws.amazon.com/marketplace/pp/B07PV3TB8X>`_. Shell access is not even required, as all configuration will happen through the Tutor web user interface. This is a commercial offer priced at $50/month ($500/year) that was created to support the development of Tutor.
Autocomplete
------------

View File

@ -1,3 +1,6 @@
-e ./plugins/minio
-e ./plugins/notes
-e ./plugins/xqueue
tutor-discovery
tutor-ecommerce
tutor-figures

View File

@ -27,20 +27,10 @@ setup(
description="The Open edX distribution for the busy system administrator",
long_description=readme,
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
package_data={"tutor": ["templates/**"]},
python_requires=">=3.5",
install_requires=[
"appdirs",
"click>=7.0",
"click_repl",
"jinja2",
"pyyaml>=4.2b1",
],
entry_points={
'console_scripts': [
'tutor=tutor.commands.cli:main',
],
},
install_requires=["appdirs", "click>=7.0", "click_repl", "jinja2", "pyyaml>=4.2b1"],
entry_points={"console_scripts": ["tutor=tutor.commands.cli:main"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",

55
tutor.spec Normal file
View File

@ -0,0 +1,55 @@
# -*- mode: python -*-
import importlib
import os
import pkg_resources
block_cipher = None
datas = [("./tutor/templates", "./tutor/templates")]
hidden_imports = []
# Auto-discover plugins and include patches & templates folders
for entrypoint in pkg_resources.iter_entry_points("tutor.plugin.v0"):
plugin_name = entrypoint.name
plugin = entrypoint.load()
plugin_root = os.path.dirname(plugin.__file__)
plugin_root_module_name = os.path.basename(plugin_root)
hidden_imports.append(entrypoint.module_name)
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)))
# 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,
)