Hi Tomasz!

tl; dr: Luckily, since you are working on widgets, you can get a taste of 
how automagic installing would work before trying it on your project with 
the widget cookiecutter 
<https://github.com/jupyter-widgets/widget-cookiecutter#usage>, which 
includes the conf.d approach 
<https://github.com/jupyter-widgets/widget-cookiecutter/blob/master/%7B%7Bcookiecutter.github_project_name%7D%7D/setup.py#L139>
.

Historically, most nbextensions on conda ran the first script (nbextension 
install) at build time, and ran the second script (nbextension enable) in 
post-link 
scripts 
<https://conda.io/docs/user-guide/tasks/build-packages/link-scripts.html>: 
here are a bunch of examples 
<https://github.com/search?q=org%3Aconda-forge+nbextension+enable&type=Code>. 
If you are in the position of having to support older notebook installs, 
this is your best bet, even though at the bottom of the page it warns 
pretty harshly against these scripts. And yeah, they do create problems.

Pure python package distributions have been able to put files in arbitrary 
locations relative to their install for a long time. Here's how ipywidgets 
does it 
<https://github.com/jupyter-widgets/ipywidgets/blob/master/widgetsnbextension/setup.py#L203>,
 
with a combination of data_files, package_data and include_package_data. In 
that last line of data_files, you'll see a reference to a directory, namely 
etc/jupyter/nbconfig/notebook.d/ . As of this PR 
<https://github.com/jupyter/notebook/pull/3116>, which landed in 5.3, an 
nbextension package only needs to write a single file 
<https://github.com/jupyter-widgets/ipywidgets/blob/master/widgetsnbextension/widgetsnbextension.json>
 
to that location to be enabled by default in the environment where it was 
installed. Hooray! Of course, you end up with some more files in your repo, 
more stuff in setup.py and MANIFEST.in, etc. Boo! But it should be a small, 
one-time effort for you, and more streamlined for your users forever. 
Hooray!

Thanks for bringing this up! It should definitely get some official 
documentation: PR started <https://github.com/jupyter/notebook/pull/3520>! 
Give it a review, any comments welcome!

Hooray!

nick

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/901bfda0-117e-412d-a8be-824cf6af4c96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to