Skip to content

Commit dcea63b

Browse files
committed
quick note for compatibility with the old Notebook
1 parent 9bb07c0 commit dcea63b

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

advanced/server-extension/README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ def _load_jupyter_server_extension(server_app):
363363
f"Registered jlab_ext_example extension at URL path /{url_path}"
364364
)
365365

366+
# For backward compatibility with the classical notebook
367+
load_jupyter_server_extension = _load_jupyter_server_extension
368+
366369
```
367370
368371
The `_jupyter_server_extension_points` provides the Python package name
@@ -523,7 +526,8 @@ labext_name = "@jupyterlab-examples/server-extension"
523526
data_files_spec = [
524527
("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"),
525528
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),
526-
("etc/jupyter/jupyter_server_config.d", "jupyter-config", "jlab_ext_example.json"),
529+
("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"),
530+
("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"),
527531
]
528532

529533
cmdclass = create_cmdclass(
@@ -589,7 +593,7 @@ the frontend NPM package needs to be built and inserted in the Python package. T
589593
done using a special `cmdclass`:
590594
591595
```py
592-
# setup.py#L38-L45
596+
# setup.py#L39-L46
593597

594598
cmdclass = create_cmdclass(
595599
"jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec
@@ -604,7 +608,7 @@ js_command = combine_commands(
604608
Basically it will build the frontend NPM package:
605609
606610
```py
607-
# setup.py#L43-L43
611+
# setup.py#L44-L44
608612

609613
install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]),
610614
```
@@ -647,10 +651,19 @@ done by copying the following JSON file:
647651
648652
in the appropriate jupyter folder (`etc/jupyter/jupyter_server_config.d`):
649653
654+
```py
655+
# setup.py#L36-L36
656+
657+
("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"),
658+
```
659+
660+
For backward compatibility with the classical notebook, the old version of that file is copied in
661+
(`etc/jupyter/jupyter_notebook_config.d`):
662+
650663
```py
651664
# setup.py#L35-L35
652665

653-
("etc/jupyter/jupyter_server_config.d", "jupyter-config", "jlab_ext_example.json"),
666+
("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"),
654667
```
655668
656669
### JupyterLab Extension Manager

advanced/server-extension/jlab_ext_example/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ def _load_jupyter_server_extension(server_app):
3030
server_app.log.info(
3131
f"Registered jlab_ext_example extension at URL path /{url_path}"
3232
)
33+
34+
# For backward compatibility with the classical notebook
35+
load_jupyter_server_extension = _load_jupyter_server_extension
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"NotebookApp": {
3+
"nbserver_extensions": {
4+
"jlab_ext_example": true
5+
}
6+
}
7+
}

advanced/server-extension/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
data_files_spec = [
3333
("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"),
3434
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),
35-
("etc/jupyter/jupyter_server_config.d", "jupyter-config", "jlab_ext_example.json"),
35+
("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"),
36+
("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"),
3637
]
3738

3839
cmdclass = create_cmdclass(

0 commit comments

Comments
 (0)