Skip to content

Commit cdc664b

Browse files
Initial Jupyter extension updates
- Updates build system to hatchling and deprecates setup.py - Bumps jupyter package compats in python and javascript
1 parent ed377cf commit cdc664b

File tree

6 files changed

+117
-150
lines changed

6 files changed

+117
-150
lines changed

webio_jupyter_extension/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Requirements
44

5-
* JupyterLab >= 3.0
5+
* JupyterLab >= 4.0
66

77
## Install
88

webio_jupyter_extension/package.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"main": "dist/labextension.js",
1515
"repository": {
1616
"type": "git",
17-
"url": "https://github.com/github_username/webio-jupyterlab-provider.git"
17+
"url": "https://github.com/JuliaGizmos/WebIO.jl.git",
18+
"directory": "webio_jupyter_extension"
1819
},
1920
"scripts": {
2021
"build": "yarn build:lib && yarn build:nbextension && yarn build:labextension:dev",
@@ -36,29 +37,29 @@
3637
"publish-pypi": "yarn build && python3 -m build && python3 -m twine upload dist/*.whl dist/*.gz "
3738
},
3839
"dependencies": {
39-
"@jupyterlab/application": "^3",
40-
"@jupyterlab/docregistry": "^3",
41-
"@jupyterlab/notebook": "^3",
42-
"@jupyterlab/rendermime": "^3",
43-
"@jupyterlab/services": "^6",
44-
"@lumino/disposable": "^1",
45-
"@lumino/widgets": "^1",
40+
"@jupyterlab/application": "^4.0.6",
41+
"@jupyterlab/docregistry": "^4.0.6",
42+
"@jupyterlab/notebook": "^4.0.6",
43+
"@jupyterlab/rendermime": "^4.0.6",
44+
"@jupyterlab/services": "^7.0.6",
45+
"@lumino/disposable": "^2.0.0",
46+
"@lumino/widgets": "^2.0.1",
4647
"@webio/webio": "portal:../packages/webio",
4748
"debug": "^4.3.2"
4849
},
4950
"devDependencies": {
50-
"@jupyterlab/builder": "^3.1.0",
51+
"@jupyterlab/builder": "^4.0.0",
5152
"@types/debug": "^4.1.7",
52-
"@types/react": "^17.0.20",
53-
"@typescript-eslint/eslint-plugin": "^4.8.1",
54-
"@typescript-eslint/parser": "^4.8.1",
55-
"eslint": "^7.14.0",
56-
"eslint-config-prettier": "^6.15.0",
57-
"eslint-plugin-prettier": "^3.1.4",
53+
"@types/react": "^18.0.26",
54+
"@typescript-eslint/eslint-plugin": "^6.1.0",
55+
"@typescript-eslint/parser": "^6.1.0",
56+
"eslint": "^8.36.0",
57+
"eslint-config-prettier": "^8.8.0",
58+
"eslint-plugin-prettier": "^5.0.0",
5859
"npm-run-all": "^4.1.5",
59-
"prettier": "^2.1.1",
60-
"rimraf": "^3.0.2",
61-
"typescript": "~4.1.3",
60+
"prettier": "^3.0.0",
61+
"rimraf": "^5.0.1",
62+
"typescript": "~5.0.2",
6263
"webpack": "^5.52.0",
6364
"webpack-cli": "^4.8.0"
6465
},
@@ -69,7 +70,7 @@
6970
"jupyter-releaser": {
7071
"hooks": {
7172
"before-build-npm": [
72-
"python -m pip install jupyterlab~=3.1",
73+
"python -m pip install jupyterlab~=4.0",
7374
"yarn"
7475
]
7576
}
Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,95 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"]
3-
build-backend = "jupyter_packaging.build_api"
2+
requires = [
3+
"hatchling>=1.5.0",
4+
"jupyterlab>=4.0.0,<5",
5+
"hatch-nodejs-version>=0.3.2"
6+
]
7+
build-backend = "hatchling.build"
48

5-
[tool.jupyter-packaging.options]
6-
skip-if-exists = ["webio_jupyter_extension/labextension/static/style.js"]
7-
ensured-targets = ["webio_jupyter_extension/labextension/static/style.js", "webio_jupyter_extension/labextension/package.json"]
9+
[project]
10+
name = "webio-jupyter-extension"
11+
readme = "README.md"
12+
license = { file = "LICENSE" }
13+
requires-python = ">=3.8"
14+
classifiers = [
15+
"Framework :: Jupyter",
16+
"Framework :: Jupyter :: JupyterLab",
17+
"Framework :: Jupyter :: JupyterLab :: 4",
18+
"Framework :: Jupyter :: JupyterLab :: Extensions",
19+
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
20+
"License :: OSI Approved :: BSD License",
21+
"Programming Language :: Python",
22+
"Programming Language :: Python :: 3",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
]
29+
dependencies = [
30+
"jupyter_server>=2.0.1,<3"
31+
]
32+
dynamic = ["version", "description", "authors", "urls", "keywords"]
833

9-
[tool.jupyter-packaging.builder]
10-
factory = "jupyter_packaging.npm_builder"
34+
[tool.hatch.version]
35+
source = "nodejs"
1136

12-
[tool.jupyter-packaging.build-args]
37+
[tool.hatch.metadata.hooks.nodejs]
38+
fields = ["description", "authors", "urls"]
39+
40+
[tool.hatch.build.targets.wheel.shared-data]
41+
"install.json" = "share/jupyter/labextensions/webio-jupyterlab-provider/install.json"
42+
"webio_jupyter_extension/labextension" = "share/jupyter/labextensions/webio-jupyterlab-provider"
43+
"webio_jupyter_extension/nbextension" = "share/jupyter/nbextensions/webio-jupyter-nbextension"
44+
"jupyter-config/notebook-config" = "etc/jupyter/nbconfig/notebook.d"
45+
"jupyter-config/server-config" = "etc/jupyter/jupyter_server_config.d"
46+
"jupyter-config/nb-config" = "etc/jupyter/jupyter_notebook_config.d"
47+
48+
[tool.hatch.build.targets.sdist]
49+
exclude = [".github", "binder"]
50+
artifacts = [
51+
"webio_jupyter_extension/labextension",
52+
"webio_jupyter_extension/nbextension"
53+
]
54+
55+
[tool.hatch.build.hooks.version]
56+
path = "webio_jupyter_extension/_version.py"
57+
58+
[tool.hatch.build.hooks.jupyter-builder]
59+
dependencies = [
60+
"hatch-jupyter-builder>=0.8.1",
61+
]
62+
build-function = "hatch_jupyter_builder.npm_builder"
63+
ensured-targets = [
64+
"webio_jupyter_extension/labextension/static/style.js",
65+
"webio_jupyter_extension/labextension/package.json",
66+
]
67+
skip-if-exists = [
68+
"webio_jupyter_extension/labextension/static/style.js",
69+
]
70+
71+
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
72+
build_dir = "webio_jupyter_extension/labextension"
73+
source_dir = "webio-jupyter-labextension"
74+
build_cmd = "install:extension"
75+
npm = [
76+
"jlpm",
77+
]
78+
79+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
1380
build_cmd = "build:prod"
1481
npm = ["jlpm"]
1582

16-
[tool.check-manifest]
17-
ignore = ["webio_jupyter_extension/labextension/**", "yarn.lock", ".*", "package-lock.json"]
83+
[tool.jupyter-releaser.options]
84+
version_cmd = "hatch version"
85+
86+
[tool.jupyter-releaser.hooks]
87+
before-build-npm = [
88+
"python -m pip install 'jupyterlab>=4.0.0,<5'",
89+
"jlpm",
90+
"jlpm build:prod"
91+
]
92+
before-build-python = ["jlpm clean:all"]
93+
94+
[tool.check-wheel-contents]
95+
ignore = ["W002"]

webio_jupyter_extension/setup.py

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,3 @@
1-
"""
2-
webio_jupyter_extension setup
3-
"""
4-
import json
5-
import sys
6-
from pathlib import Path
7-
8-
import setuptools
9-
10-
HERE = Path(__file__).parent.resolve()
11-
12-
# The name of the project
13-
name = "webio_jupyter_extension"
14-
15-
lab_path = (HERE / name.replace("-", "_") / "labextension")
16-
nbextension_path = (HERE / name.replace("-", "_") / "nbextension")
17-
18-
# Representative files that should exist after a successful build
19-
ensured_targets = [
20-
str(lab_path / "package.json"),
21-
str(lab_path / "static/style.js")
22-
]
23-
24-
# Get the package info from package.json
25-
pkg_json = json.loads((HERE / "package.json").read_bytes())
26-
labext_name = pkg_json["name"]
27-
28-
data_files_spec = [
29-
# labextension files
30-
(f"share/jupyter/labextensions/{labext_name}", str("."), "install.json"),
31-
(f"share/jupyter/labextensions/{labext_name}", str(lab_path.relative_to(HERE)), "**"),
32-
33-
# nbextension files
34-
('share/jupyter/nbextensions/webio-jupyter-nbextension', str(nbextension_path.relative_to(HERE)), '**'),
35-
('etc/jupyter/nbconfig/notebook.d' , "jupyter-config/notebook-config", 'webio-jupyter-nbextension.json'),
36-
37-
# serverextension files
38-
("etc/jupyter/jupyter_server_config.d", "jupyter-config/server-config", f"{name}.json"),
39-
# For backward compatibility with notebook server
40-
("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/nb-config", f"{name}.json"),
41-
]
42-
43-
long_description = (HERE / "README.md").read_text()
44-
45-
46-
setup_args = dict(
47-
name=name,
48-
version=pkg_json["version"],
49-
description=pkg_json["description"],
50-
license=pkg_json["license"],
51-
long_description=long_description,
52-
long_description_content_type="text/markdown",
53-
packages=setuptools.find_packages(),
54-
install_requires=[],
55-
zip_safe=False,
56-
include_package_data=True,
57-
python_requires=">=3.6",
58-
platforms="Linux, Mac OS X, Windows",
59-
keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
60-
classifiers=[
61-
"License :: OSI Approved :: BSD License",
62-
"Programming Language :: Python",
63-
"Programming Language :: Python :: 3",
64-
"Programming Language :: Python :: 3.6",
65-
"Programming Language :: Python :: 3.7",
66-
"Programming Language :: Python :: 3.8",
67-
"Programming Language :: Python :: 3.9",
68-
"Framework :: Jupyter",
69-
"Framework :: Jupyter :: JupyterLab",
70-
"Framework :: Jupyter :: JupyterLab :: 3",
71-
"Framework :: Jupyter :: JupyterLab :: Extensions",
72-
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
73-
],
74-
)
75-
76-
try:
77-
from jupyter_packaging import (
78-
wrap_installers,
79-
npm_builder,
80-
get_data_files
81-
)
82-
post_develop = npm_builder(
83-
build_cmd="install:extension", source_dir="src", build_dir=lab_path
84-
)
85-
setup_args["cmdclass"] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)
86-
setup_args["data_files"] = get_data_files(data_files_spec)
87-
except ImportError as e:
88-
import logging
89-
logging.basicConfig(format="%(levelname)s: %(message)s")
90-
logging.warning("Build tool `jupyter-packaging` is missing. Install it with pip or conda.")
91-
if not ("--name" in sys.argv or "--version" in sys.argv):
92-
raise e
93-
94-
if __name__ == "__main__":
95-
setuptools.setup(**setup_args)
1+
# setup.py shim for use with versions of JupyterLab that require
2+
# it for extensions.
3+
__import__("setuptools").setup()

webio_jupyter_extension/webio_jupyter_extension/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44

55
from ._version import __version__
66

7-
HERE = Path(__file__).parent.resolve()
8-
9-
with (HERE / "labextension" / "package.json").open() as fid:
10-
data = json.load(fid)
11-
12-
137
def _jupyter_labextension_paths():
148
return [{
159
"src": "labextension",
16-
"dest": data["name"]
10+
"dest": "webio-jupyterlab-provider"
1711
}]
1812

1913

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
import json
2-
from pathlib import Path
3-
4-
__all__ = ["__version__"]
5-
6-
def _fetchVersion():
7-
HERE = Path(__file__).parent.resolve()
8-
9-
for settings in HERE.rglob("package.json"):
10-
try:
11-
with settings.open() as f:
12-
return json.load(f)["version"]
13-
except FileNotFoundError:
14-
pass
15-
16-
raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}")
17-
18-
__version__ = _fetchVersion()
1+
# This file is auto-generated by Hatchling. As such, do not:
2+
# - modify
3+
# - track in version control e.g. be sure to add to .gitignore
4+
__version__ = VERSION = '0.2.0'

0 commit comments

Comments
 (0)