Merge pull request #1022 from jdfreder/smallsplit

Update the notebook widget hack to reference the new jupyter-js-widgets-nbextension package
This commit is contained in:
Jonathan Frederic 2016-02-03 10:35:53 -08:00
commit df964650fd
3 changed files with 16 additions and 7 deletions

View File

@ -79,7 +79,7 @@ RUN BUILD_DEPS="nodejs-legacy npm" && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq $BUILD_DEPS && \
\
pip3 install --no-cache-dir /usr/src/jupyter-notebook && \
pip3 install ipywidgets && \
pip3 install widgetsnbextension && \
\
npm cache clean && \
apt-get clean && \

View File

@ -239,16 +239,21 @@ class NotebookWebApplication(web.Application):
handlers.extend(load_handlers('services.security.handlers'))
# BEGIN HARDCODED WIDGETS HACK
widgets = None
try:
import ipywidgets
import widgetsnbextension as widgets
except:
try:
import ipywidgets as widgets
except:
app_log.warning('Widgets are unavailable. Please install widgetsnbextension or ipywidgets 4.0')
if widgets is not None:
handlers.append(
(r"/nbextensions/widgets/(.*)", FileFindHandler, {
'path': ipywidgets.find_static_assets(),
'path': widgets.find_static_assets(),
'no_cache_paths': ['/'], # don't cache anything in nbextensions
}),
)
except:
app_log.warning('ipywidgets package not installed. Widgets are unavailable.')
# END HARDCODED WIDGETS HACK
handlers.append(

View File

@ -55,8 +55,12 @@ require([
"use strict";
// BEGIN HARDCODED WIDGETS HACK
utils.load_extension('widgets/notebook/js/extension').catch(function () {
console.warn('ipywidgets package not installed. Widgets are not available.');
// Try to load the new extension
utils.load_extension('widgets/extension').catch(function () {
// Fallback to the ipywidgets extension
utils.load_extension('widgets/notebook/js/extension').catch(function () {
console.warn('Widgets are not available. Please install widgetsnbextension or ipywidgets 4.0');
});
});
// END HARDCODED WIDGETS HACK