Skip to content

Commit 7d261db

Browse files
committed
add bundled server extension
1 parent 45dc001 commit 7d261db

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed
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+
"lab_extension": true
5+
}
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ServerApp": {
3+
"jpserver_extensions": {
4+
"lab_extension": true
5+
}
6+
}
7+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import contextlib
2+
3+
4+
def _load_jupyter_server_extension(server_app):
5+
"""Sets PageConfig nbclassic_enabled depending on if nbclassic is installed
6+
7+
Parameters
8+
----------
9+
server_app: jupyterlab.labapp.LabApp
10+
JupyterLab application instance
11+
"""
12+
nbclassic_enabled = False
13+
with contextlib.suppress(AttributeError):
14+
nbclassic_enabled = server_app.nbserver_extensions.get("nbclassic", False)
15+
16+
from jupyterlab.labapp import LabApp
17+
18+
LabApp.app_instance.page_config_data = {"nbclassic_enabled": nbclassic_enabled}
19+
20+
21+
# For backward compatibility with notebook server - useful for Binder/JupyterHub
22+
load_jupyter_server_extension = _load_jupyter_server_extension
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
[build-system]
2+
requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "lab_extension"
7+
readme = "README.md"
8+
license = { file = "LICENSE" }
9+
requires-python = ">=3.8"
10+
classifiers = [
11+
"Framework :: Jupyter",
12+
"Framework :: Jupyter :: JupyterLab",
13+
"Framework :: Jupyter :: JupyterLab :: 4",
14+
"Framework :: Jupyter :: JupyterLab :: Extensions",
15+
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
16+
"License :: OSI Approved :: BSD License",
17+
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
]
24+
dependencies = [
25+
"jupyter_server>=2.0.1,<3"
26+
]
27+
dynamic = ["version", "description", "authors", "urls", "keywords"]
28+
29+
[tool.hatch.version]
30+
source = "nodejs"
31+
32+
[tool.hatch.metadata.hooks.nodejs]
33+
fields = ["description", "authors", "urls"]
34+
35+
[tool.hatch.build.targets.sdist]
36+
artifacts = ["lab_extension/labextension"]
37+
exclude = [".github", "binder"]
38+
39+
[tool.hatch.build.targets.wheel.shared-data]
40+
"lab_extension/labextension" = "share/jupyter/labextensions/lab-extension"
41+
"install.json" = "share/jupyter/labextensions/lab-extension/install.json"
42+
"jupyter-config/server-config" = "etc/jupyter/jupyter_server_config.d"
43+
"jupyter-config/nb-config" = "etc/jupyter/jupyter_notebook_config.d"
44+
45+
[tool.hatch.build.hooks.version]
46+
path = "lab_extension/_version.py"
47+
48+
[tool.hatch.build.hooks.jupyter-builder]
49+
dependencies = ["hatch-jupyter-builder>=0.5"]
50+
build-function = "hatch_jupyter_builder.npm_builder"
51+
ensured-targets = [
52+
"lab_extension/labextension/static/style.js",
53+
"lab_extension/labextension/package.json",
54+
]
55+
skip-if-exists = ["lab_extension/labextension/static/style.js"]
56+
57+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
58+
build_cmd = "build:prod"
59+
npm = ["jlpm"]
60+
61+
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
62+
build_cmd = "install:extension"
63+
npm = ["jlpm"]
64+
source_dir = "src"
65+
build_dir = "lab_extension/labextension"
66+
67+
[tool.jupyter-releaser.options]
68+
version_cmd = "hatch version"
69+
70+
[tool.jupyter-releaser.hooks]
71+
before-build-npm = [
72+
"python -m pip install 'jupyterlab>=4.0.0,<5'",
73+
"jlpm",
74+
"jlpm build:prod"
75+
]
76+
before-build-python = ["jlpm clean:all"]
77+
78+
[tool.check-wheel-contents]
79+
ignore = ["W002"]

packages/lab-extension/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__("setuptools").setup()

0 commit comments

Comments
 (0)