ipython-contrib / jupyter_contrib_nbextensions

A collection of various notebook extensions for Jupyter
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest
Other
5.21k stars 806 forks source link

toc: one liner for install? #947

Open cqcn1991 opened 7 years ago

cqcn1991 commented 7 years ago

Just want to add another hack to toc2 (https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tree/master/src/jupyter_contrib_nbextensions/nbextensions/toc2), that is, install it standalone by command, not sure if it is possible or encouraged?

I see it is possible for RISE, https://github.com/damianavila/RISE, whichi you can install it simply by

conda install -c damianavila82 rise

Not sure if this would also be OK for upgrading the extentions?

I see the benefit that people can try one pluggin very quickly, instead of installing a bunch of pluggins that they may not need.

jcb91 commented 7 years ago

A true one-step install is unfortunately only possible for those using conda. We already have such a procedure for this repo, in the form of

conda install -c conda-forge jupyter_contrib_nbextensions

For individual nbextensions to be installed independently, they need to be packaged independently. This is already done for a few which are included as dependencies rather than duplicating their code: jupyter_latex_envs and jupyter_highlight_selected_word both provide standalone conda recipes on the conda-forge channel for single-line installs.

Ultimately it comes down to a trade-off between extra copy-paste lines for the user, or extra complexity and potential headache for the developer!

cqcn1991 commented 7 years ago

@jcb91 I think conda install is OK, since most Sci-Py users install using anaconda.

Just to be sure: to installed one extention independely, we need to move it into a standalone git repo? It can't be done within the jupyter_contrib_nbextensions?

Is it possible to have a standalone github repo for toc2, and have some program automatically sync these 2?

jcb91 commented 7 years ago

to installed one extention independely, we need to move it into a standalone git repo?

The git repo isn't important, that could be the same (although it gets more confusing for people as things get less standard). The key point is that they'd need to be packaged (in a conda channel) separately if you want to be able to run only a single command.

It can't be done within the jupyter_contrib_nbextensions?

I'm not really sure what you mean by this, but I'm guessing you mean running something like jupyter contrib nbextensions install --nbext toc2? This would mean having lots of install scripts in this repo, and still wouldn't really make life any easier, because you'd still need to install this repo in order to run the jupyter contrib nbextensions command. Alternatively, if you meant making a conda recipe for standalone toc2 from this repo, that might be possible for simple nbextensions (no python). However,t toc2 provides python items (nbconvert support classes), which need to be installed correctly as part of a python package. This is currently part of the jupyter_contrib_nbextensions package, so separating it would mean a separate pypi package, which to me would make a separate git repo much more sensible, but increase the maintenance overhead considerably.

To be honest, as I see it, the downsides of this far outweigh the potential upsides (which is basically just a slightly shorter download time for anyone wishing to install only a single nbextension, and given modern broadband speeds, it's not that slow anyway).

jcb91 commented 7 years ago

Is it possible to have a standalone github repo for toc2, and have some program automatically sync these 2?

Sort of. As I mentioned, jupyter_latex_envs and jupyter_highlight_selected_word both have standalone github repos, plus associated pypi packages jupyter_latex_envs and jupyter_highlight_selected_word, and conda-forge recipes jupyter_latex_envs-feedstock and jupyter_highlight_selected_word-feedstock. As a result, you can

conda install -c conda-forge jupyter_highlight_selected_word

But, it's quite a bit of extra gubbins to manage!

jfbercher commented 7 years ago

Yes, sure, it would need much more extra work and maintenance.

cqcn1991 commented 7 years ago

Thanks for @jcb91 , seems like pretty difficult to make it work.

Just to clarify reasons for the 1-liner, they are pretty simple:

  1. We can post the toc2 at Hacker News and other places, and it would be much easier for people to try it than the whole nbextentions. I guess that this (and some other) extension is pretty valuable, but people simply don't know it, or the install procedure is not that handy.

  2. I'd like to include toc2 into my own research, to make my readers lifes easier. So I want some similar like pip install -r requirements.txt. Asking them to install all packages at once is not really a good idea.

jfbercher commented 7 years ago

A simple solution that I use from time to time (fast installation with simple instructions + scriptable) is to install from an archive. The drawback is that the installation misses the export capabilities (templates) and entry points, which needs a python module.

jupyter nbextension install https://rawgit.com/jfbercher/small_nbextensions/master/toc2.zip  --user
jupyter nbextension enable toc2/main 

[I just updated the archive to the last version]

jcb91 commented 7 years ago

seems like pretty difficult to make it work.

Not difficult as such, just a bit of a faff :laughing:

:+1: to @jfbercher's archive suggestion. This is a neat solution for nbextensions without server-side python or nbconvert stuff, and allows you to use the built-in nbextensions command, although it does require a whole two commands ;).