[Python-modules-commits] [jupyter-notebook] 01/02: Don't automatically import ipywidgets

Gordon Ball chronitis-guest at moszumanska.debian.org
Mon Dec 19 14:44:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

chronitis-guest pushed a commit to branch master
in repository jupyter-notebook.

commit 34dce50bd79f3210b5ff81c3de3158dff27eb0de
Author: Gordon Ball <gordon at chronitis.net>
Date:   Sat Dec 17 16:46:56 2016 +0100

    Don't automatically import ipywidgets
    
    ipywidgets.find_static_assets() is a no-op for ipywidgets > 4, which instead
    use the nbextensions mechanism, but causes a warning to be shown if the
    (redundant) widgetsnbextension package is not installed
    
    Instead, a check is made whether the extensions.js file for the widgets is
    available, and if not, a warning is shown advising the user of the deb
    package to install
---
 notebook/notebookapp.py | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py
index ab73020..7cef60f 100644
--- a/notebook/notebookapp.py
+++ b/notebook/notebookapp.py
@@ -233,24 +233,23 @@ class NotebookWebApplication(web.Application):
         handlers.extend(load_handlers('services.nbconvert.handlers'))
         handlers.extend(load_handlers('services.kernelspecs.handlers'))
         handlers.extend(load_handlers('services.security.handlers'))
-        
-        # BEGIN HARDCODED WIDGETS HACK
-        # TODO: Remove on notebook 5.0
+
+        # debian-specific
+        # check for installation of the ipywidgets server support, and advise how
+        # to install it if it's unavailable
+        # replaces a previous hardcoded attempt to import ipywidgets
+
+        deb_widgets_js = "/usr/share/jupyter/nbextensions/jupyter-js-widgets/extension.js"
+        has_widgetsnbextension = False
         try:
             import widgetsnbextension
+            has_widgetsnbextension = True
         except:
-            try:
-                import ipywidgets as widgets
-                handlers.append(
-                    (r"/nbextensions/widgets/(.*)", FileFindHandler, {
-                        'path': widgets.find_static_assets(),
-                        'no_cache_paths': ['/'], # don't cache anything in nbextensions
-                    }),
-                )
-            except:
-                app_log.warning('Widgets are unavailable. Please install widgetsnbextension or ipywidgets 4.0')
-        # END HARDCODED WIDGETS HACK
-        
+            pass
+
+        if not (os.path.exists(deb_widgets_js) or has_widgetsnbextension):
+            app_log.warning("Widgets are unavailable. On Debian, notebook support for widgets is provided by the package jupyter-nbextension-jupyter-js-widgets")
+
         handlers.append(
             (r"/nbextensions/(.*)", FileFindHandler, {
                 'path': settings['nbextensions_path'],

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/jupyter-notebook.git



More information about the Python-modules-commits mailing list