diff --git a/jupyterhub/app.py b/jupyterhub/app.py index ca0e6f3f..ef519507 100644 --- a/jupyterhub/app.py +++ b/jupyterhub/app.py @@ -31,15 +31,11 @@ from tornado.ioloop import IOLoop, PeriodicCallback from tornado.log import app_log, access_log, gen_log from tornado import gen, web -import IPython -if V(IPython.__version__) < V('3.0'): - raise ImportError("JupyterHub Requires IPython >= 3.0, found %s" % IPython.__version__) - -from IPython.utils.traitlets import ( +from traitlets import ( Unicode, Integer, Dict, TraitError, List, Bool, Any, Type, Set, Instance, Bytes, Float, ) -from IPython.config import Application, catch_config_error +from traitlets.config import Application, catch_config_error here = os.path.dirname(__file__) diff --git a/jupyterhub/auth.py b/jupyterhub/auth.py index 74427d1e..935c2367 100644 --- a/jupyterhub/auth.py +++ b/jupyterhub/auth.py @@ -10,8 +10,8 @@ from subprocess import check_call, check_output, CalledProcessError from tornado import gen import simplepam -from IPython.config import LoggingConfigurable -from IPython.utils.traitlets import Bool, Set, Unicode, Any +from traitlets.config import LoggingConfigurable +from traitlets import Bool, Set, Unicode, Any from .handlers.login import LoginHandler from .utils import url_path_join diff --git a/jupyterhub/singleuser.py b/jupyterhub/singleuser.py index 51db52ec..b42594bc 100644 --- a/jupyterhub/singleuser.py +++ b/jupyterhub/singleuser.py @@ -17,7 +17,7 @@ from jinja2 import ChoiceLoader, FunctionLoader from tornado import ioloop from tornado.web import HTTPError -from IPython.utils.traitlets import ( +from traitlets import ( Integer, Unicode, CUnicode, diff --git a/jupyterhub/spawner.py b/jupyterhub/spawner.py index bdf4f351..00f713a3 100644 --- a/jupyterhub/spawner.py +++ b/jupyterhub/spawner.py @@ -16,8 +16,8 @@ from tempfile import TemporaryDirectory from tornado import gen from tornado.ioloop import IOLoop, PeriodicCallback -from IPython.config import LoggingConfigurable -from IPython.utils.traitlets import ( +from traitlets.config import LoggingConfigurable +from traitlets import ( Any, Bool, Dict, Enum, Instance, Integer, Float, List, Unicode, ) diff --git a/jupyterhub/tests/test_traitlets.py b/jupyterhub/tests/test_traitlets.py index 3ede4ea9..73eef270 100644 --- a/jupyterhub/tests/test_traitlets.py +++ b/jupyterhub/tests/test_traitlets.py @@ -1,7 +1,4 @@ -try: - from traitlets import HasTraits -except ImportError: - from IPython.utils.traitlets import HasTraits +from traitlets import HasTraits from jupyterhub.traitlets import URLPrefix, Command diff --git a/jupyterhub/traitlets.py b/jupyterhub/traitlets.py index d838895c..f9542747 100644 --- a/jupyterhub/traitlets.py +++ b/jupyterhub/traitlets.py @@ -2,7 +2,7 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -from IPython.utils.traitlets import List, Unicode +from traitlets import List, Unicode class URLPrefix(Unicode): def validate(self, obj, value): diff --git a/jupyterhub/utils.py b/jupyterhub/utils.py index 80a58094..26b7cfed 100644 --- a/jupyterhub/utils.py +++ b/jupyterhub/utils.py @@ -14,11 +14,6 @@ from tornado import web, gen, ioloop from tornado.httpclient import AsyncHTTPClient, HTTPError from tornado.log import app_log -try: - from jupyter_notebook.utils import url_path_join -except: - from IPython.html.utils import url_path_join - def random_port(): """get a single random port""" @@ -172,5 +167,26 @@ def compare_token(compare, token): if compare == hashed: return True return False - + +def url_path_join(*pieces): + """Join components of url into a relative url + + Use to prevent double slash when joining subpath. This will leave the + initial and final / in place + + Copied from notebook.utils.url_path_join + """ + initial = pieces[0].startswith('/') + final = pieces[-1].endswith('/') + stripped = [ s.strip('/') for s in pieces ] + result = '/'.join(s for s in stripped if s) + + if initial: + result = '/' + result + if final: + result = result + '/' + if result == '//': + result = '/' + + return result diff --git a/requirements.txt b/requirements.txt index 0f42f481..17ab63d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ipython>=3 +traitlets>=4 tornado>=4 jinja2 simplepam