Browse Source

enable jupyterlab to work as a classic notebook extension and fix handling of binder

bump jupyter_server dependency version

update binder link to use jupyter server

bump versions

Use notebook to launch

make sure JupyterLab still runs under classic notebook

fix handling of static url when there is a base_url

switch to use url_path_join from jupyter_server in static url

Run jupyter lab --dev-mode directly

bump server dep

Revert "Run jupyter lab --dev-mode directly"

This reverts commit 22a92401c2641dce1140e6fe784181db0290eb89.
Zsailer 4 years ago
parent
commit
678646cec1

+ 4 - 4
binder/jupyter_notebook_config.py

@@ -5,12 +5,12 @@ lab_command = ' '.join([
     '--debug',
     '--no-browser',
     '--port={port}',
-    '--NotebookApp.ip=127.0.0.1',
-    '--NotebookApp.token=""',
-    '--NotebookApp.base_url={base_url}lab-dev',
+    '--ServerApp.ip=127.0.0.1',
+    '--ServerApp.token=""',
+    '--ServerApp.base_url={base_url}lab-dev',
     # Disable dns rebinding protection here, since our 'Host' header
     # is not going to be localhost when coming from hub.mybinder.org
-    '--NotebookApp.allow_remote_access=True'
+    '--ServerApp.allow_remote_access=True'
 ])
 
 c.ServerProxy.servers = {

+ 1 - 4
binder/postBuild

@@ -5,7 +5,4 @@ pip install -e .
 
 jlpm
 
-jlpm build
-
-# This seems to be explicitly needed with `pip install -e .`
-jupyter serverextension enable jupyterlab --sys-prefix
+jlpm build

+ 1 - 1
binder/start

@@ -6,4 +6,4 @@ import os
 argv = sys.argv[1:] + ['--config', 'binder/jupyter_notebook_config.py']
 print(argv)
 
-os.execv(shutil.which(argv[0]), argv)
+os.execv(shutil.which(argv[0]), argv)

+ 0 - 0
etc/jupyter/jupyter_notebook_config.d/jupyterlab.json → jupyter-config/jupyter_notebook_config.d/jupyterlab.json


+ 10 - 0
jupyterlab/__init__.py

@@ -5,6 +5,16 @@
 
 from ._version import __version__
 from .labapp import LabApp
+from .serverextension import load_jupyter_server_extension
+
+
+def _jupyter_server_extension_paths():
+    return [
+        {
+            'module': 'jupyterlab'
+        }
+    ]
+
 
 def _jupyter_server_extension_points():
     return [

+ 29 - 1
jupyterlab/browser_check.py

@@ -193,10 +193,38 @@ def _jupyter_server_extension_points():
             }
         ]
 
+
+# TODO: remove handling of --notebook arg and the following two
+# functions in JupyterLab 4.0
+def load_jupyter_server_extension(serverapp):
+    extension = BrowserApp()
+    extension.serverapp = serverapp
+    extension.load_config_file()
+    extension.update_config(serverapp.config)
+    extension.parse_command_line(serverapp.extra_args)
+    extension.initialize()
+
+
+def _jupyter_server_extension_paths():
+    return [
+        {
+            'module': 'jupyterlab.browser_check'
+        }
+    ]
+
+
 if __name__ == '__main__':
     skip_option = "--no-chrome-test"
     if skip_option in sys.argv:
         BrowserApp.test_browser = False
         sys.argv.remove(skip_option)
 
-    BrowserApp.launch_instance()
+    if "--notebook" in sys.argv:
+        from notebook.notebookapp import NotebookApp
+        NotebookApp.default_url = "/lab"
+        sys.argv.remove("--notebook")
+        NotebookApp.nbserver_extensions = {"jupyterlab.browser_check": True}
+        NotebookApp.open_browser = False
+        NotebookApp.launch_instance()
+    else:
+        BrowserApp.launch_instance()

+ 2 - 1
jupyterlab/labapp.py

@@ -584,8 +584,9 @@ class LabApp(NBClassicConfigShimMixin, LabServerApp):
         if self.override_static_url:
             return self.override_static_url
         else:
-            return "/static/{name}/".format(
+            static_url = "/static/{name}/".format(
             name=self.name)
+            return ujoin(self.serverapp.base_url, static_url)
 
     @default('theme_url')
     def _default_theme_url(self):

+ 13 - 0
jupyterlab/serverextension.py

@@ -0,0 +1,13 @@
+from .labapp import LabApp
+
+
+def load_jupyter_server_extension(serverapp):
+    """Temporary server extension shim when using
+    old notebook server.
+    """
+    extension = LabApp()
+    extension.serverapp = serverapp
+    extension.load_config_file()
+    extension.update_config(serverapp.config)
+    extension.parse_command_line(serverapp.extra_args)
+    extension.initialize()

+ 3 - 0
scripts/ci_script.sh

@@ -213,6 +213,9 @@ if [[ $GROUP == usage ]]; then
     jupyter labextension enable -h
     jupyter labextension disable -h
 
+    # Make sure we can run JupyterLab under classic notebook
+    python -m jupyterlab.browser_check --notebook
+
     # Make sure we can add and remove a sibling package.
     # jlpm run add:sibling jupyterlab/tests/mock_packages/extension
     # jlpm run build

+ 4 - 2
setup.py

@@ -45,6 +45,8 @@ data_files_spec = [
     ('share/jupyter/lab/themes', '%s/themes' % NAME, '**'),
     ('etc/jupyter/jupyter_server_config.d',
      'jupyter-config/jupyter_server_config.d', 'jupyterlab.json'),
+    ('etc/jupyter/jupyter_notebook_config.d',
+     'jupyter-config/jupyter_notebook_config.d', 'jupyterlab.json'),
 ]
 
 package_data_spec = dict()
@@ -152,8 +154,8 @@ setup_args['install_requires'] = [
     'ipython',
     'tornado!=6.0.0, !=6.0.1, !=6.0.2',
     'jupyterlab_server~=2.0.0b7',
-    'jupyter_server~=1.0.0rc13',
-    'nbclassic~=0.2.0rc4',
+    'jupyter_server~=1.0.0rc16',
+    'nbclassic~=0.2.0rc7',
     'jinja2>=2.10'
 ]