From 411a7a0bd896915471e816fd96d242667d3b4245 Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 24 Sep 2015 16:13:28 +0200 Subject: [PATCH] single-user imports notebook package directly instead of relying on IPython.html shims when should we drop support for IPython 3? --- jupyterhub/singleuser.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/jupyterhub/singleuser.py b/jupyterhub/singleuser.py index d482eabd..21cc0ba2 100644 --- a/jupyterhub/singleuser.py +++ b/jupyterhub/singleuser.py @@ -24,18 +24,28 @@ from IPython.utils.traitlets import ( CUnicode, ) -from IPython.html.notebookapp import NotebookApp, aliases as notebook_aliases -from IPython.html.auth.login import LoginHandler -from IPython.html.auth.logout import LogoutHandler +try: + import notebook + # 4.x +except ImportError: + from IPython.html.notebookapp import NotebookApp, aliases as notebook_aliases + from IPython.html.auth.login import LoginHandler + from IPython.html.auth.logout import LogoutHandler -from IPython.html.utils import url_path_join + from IPython.html.utils import url_path_join + from distutils.version import LooseVersion as V -from distutils.version import LooseVersion as V + import IPython + if V(IPython.__version__) < V('3.0'): + raise ImportError("JupyterHub Requires IPython >= 3.0, found %s" % IPython.__version__) +else: + from notebook.notebookapp import NotebookApp, aliases as notebook_aliases + from notebook.auth.login import LoginHandler + from notebook.auth.logout import LogoutHandler + + from notebook.utils import url_path_join -import IPython -if V(IPython.__version__) < V('3.0'): - raise ImportError("JupyterHub Requires IPython >= 3.0, found %s" % IPython.__version__) # Define two methods to attach to AuthenticatedHandler, # which authenticate via the central auth server.