5

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?

das-g
  • 9,718
  • 4
  • 38
  • 80
  • The reason why I think `pipenv` might be (or may become) able to do that is that Rust's `cargo` (which AFAIK can do more than just package/environment managing) is mentioned on https://docs.pipenv.org/ . Though maybe that just refers to the package managing part of `cargo (and the ability to run command in the managed environments), not its other capabilities? – das-g Feb 10 '18 at 21:58
  • The reason why I think it may be possible from within the notebook (with some user-aided execution, so not fully automated), is that I've seen [some (older, maybe outdated?) nbextension instructions](https://mindtrove.info/4-ways-to-extend-jupyter-notebook/#nb-extensions) that had the user `import notebook.nbextensions` and then run the `install_nbextension()` function from there, followed by Jupyter-javascript-Magic to load the extension. – das-g Feb 10 '18 at 22:05

1 Answers1

1

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.

philngo
  • 913
  • 7
  • 12
  • Ah, thanks. I suspected this may be the case, but thought I may be missing something. About the `nbextension`commands, though: Aren't they moving (and/or copying/creating) files around _within_ the current virtualenv (when used with `--sys-prefix`)? If not, from where to where do they move or copy stuff? – das-g Feb 10 '18 at 21:43