#!/usr/bin/env bash
set -exuo pipefail

export SRC_DIR="${PWD}"

# enable stencila-proxy extension
python setup.py build_py
pip install -e .
jupyter serverextension enable --sys-prefix --py nbstencilaproxy
jupyter nbextension install    --sys-prefix --py nbstencilaproxy
jupyter nbextension enable     --sys-prefix --py nbstencilaproxy

# enable stencila python context
python -m stencila register

# set environment variables via notebook config
mkdir -p ~/.jupyter
cat >> ~/.jupyter/jupyter_notebook_config.py <<EOF

import os
os.environ["STENCILA_ARCHIVE_DIR"] = "${SRC_DIR}/archive"
os.environ["STENCILA_ARCHIVE"] = "py-jupyter"

EOF
