mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Add a simple installer!
Sortof re-invents what debian packages do a little bit.
This commit is contained in:
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include tljh/systemd-units/*
|
||||||
49
tljh/installer.py
Normal file
49
tljh/installer.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import tljh.systemd as systemd
|
||||||
|
import tljh.conda as conda
|
||||||
|
|
||||||
|
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
|
||||||
|
HUB_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'hub')
|
||||||
|
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
|
||||||
|
|
||||||
|
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_jupyterhub_service(prefix):
|
||||||
|
with open(os.path.join(HERE, 'systemd-units', 'jupyterhub.service')) as f:
|
||||||
|
unit_template = f.read()
|
||||||
|
|
||||||
|
unit = unit_template.format(
|
||||||
|
python_interpreter_path=sys.executable,
|
||||||
|
jupyterhub_config_path=os.path.join(HERE, 'jupyterhub_config.py'),
|
||||||
|
prefix=prefix
|
||||||
|
)
|
||||||
|
systemd.install_unit('jupyterhub.service', unit)
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_jupyterhub_package(prefix):
|
||||||
|
"""
|
||||||
|
Install JupyterHub into our conda environment if needed.
|
||||||
|
|
||||||
|
Conda constructor does not play well with conda-forge, so we can ship this
|
||||||
|
with constructor
|
||||||
|
"""
|
||||||
|
# FIXME: Use fully deterministic package lists here
|
||||||
|
conda.ensure_conda_packages(prefix, ['jupyterhub==0.9.0'])
|
||||||
|
conda.ensure_pip_packages(prefix, [
|
||||||
|
'jupyterhub-dummyauthenticator==0.3.1',
|
||||||
|
'jupyterhub-systemdspawner==0.9.12'
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
ensure_jupyterhub_package(HUB_ENV_PREFIX)
|
||||||
|
ensure_jupyterhub_service(HUB_ENV_PREFIX)
|
||||||
|
|
||||||
|
conda.ensure_conda_env(USER_ENV_PREFIX)
|
||||||
|
conda.ensure_conda_packages(USER_ENV_PREFIX, [
|
||||||
|
'jupyterhub==0.9.0',
|
||||||
|
'notebook==5.5.0'
|
||||||
|
])
|
||||||
|
systemd.reload_daemon()
|
||||||
|
systemd.start_service('jupyterhub')
|
||||||
12
tljh/systemd-units/jupyterhub.service
Normal file
12
tljh/systemd-units/jupyterhub.service
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Template file for JupyterHub systemd service
|
||||||
|
# Runs both JupyterHub and ConfigurableHTTPProxy
|
||||||
|
# Uses simple string.format() for 'templating'
|
||||||
|
[Unit]
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
Restart=always
|
||||||
|
StateDirectory=jupyterhub
|
||||||
|
WorkingDirectory=/var/lib/jupyterhub
|
||||||
|
ExecStart={python_interpreter_path} -m jupyterhub.app -f {jupyterhub_config_path}
|
||||||
Reference in New Issue
Block a user