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, which includes the
conf.d approach.
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: here are a
bunch of examples. 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, 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, which landed in 5.3, an nbextension package only needs to write a
single file 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! Give it a review, any comments welcome!
Hooray!
nick