I'd like to make interactive slide set (for a presentation with some live coding in python) with RISE a.k.a. live_reveal, which is a notebook extension for Jupyter.
I'd like the slide set to be usable by others (and by my future self) without too many manual steps (and without relying on hosted Jupyter solutions), thus I've chosen pipenv
to manage dependencies.
I can get started with
pipenv install RISE
pipenv run jupyter nbextension install rise --py --sys-prefix
pipenv run jupyter nbextension enable rise --py --sys-prefix
pipenv run jupyter notebook # to start the jupyter server
However, only pipenv install RISE
leaves traces in the local directory (in Pipfile
and Pipfile.lock
). So, when using my files on a new machine (or after pipenv --rm
) just
pipenv install
pipenv run jupyter notebook
won't suffice. The two nbextension
steps will have to be repeated to enable the RISE extension and have the button available in Jupyter notebooks to switch to presentation mode.
Can this be automated? (Without employing additional tools like conda, docker, vagrant, make or other build systems, ...) If so, how should it be automated?
Can I tell pipenv
(e.g. in Pipfile
) to run these two commands after package installation? Or should I let the notebook (the *.ipynb
file) load the extensions somehow?
This is out of scope for pipenv. Pipenv manages your python environment - i.e., which packages are installed - and really nothing more. (The one exception to this is that environment variables in a .env
file are loaded on pipenv run
or pipenv shell
commands). The nbextension commands you listed in your question are actually not dealing with the python environment at all, but are moving javascript and css files around (install rise
) and creating (or editing, if you had other nbextensions installed) a json config file (enable rise
).
For better or for worse, pipenv does not have anything like a postinstall hook for running arbitrary build commands. Nor does jupyter seem to have a way to prepackage or automatically install extensions, although I may be wrong about that.
My personal opinion is that making this sort of thing repeatable is exactly what the build tools you mentioned are great for. Your best bet without using a build tools of the sort you mentioned you would rather not use is to write a clear readme or maybe your own (documented) postinstall shell script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With