Skip to content

Commit a52709c

Browse files
authored
Update example to use hatch (#1169)
Fixes #858
1 parent a6dea1b commit a52709c

File tree

6 files changed

+45
-211
lines changed

6 files changed

+45
-211
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ docs/source/other/full-config.rst
4747
.history
4848
.vscode/*
4949
!.vscode/*.template
50+
51+
# Compiled static file in example.
52+
examples/simple/simple_ext1/static/bundle.js

examples/simple/pyproject.toml

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.5.0", "setuptools>=40.8.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling","hatch-nodejs-version"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "jupyter-server-example"
7+
description = "Jupyter Server Example"
8+
readme = "README.md"
9+
license = ""
10+
requires-python = ">=3.8"
11+
dependencies = [
12+
"jinja2",
13+
"jupyter_server",
14+
]
15+
dynamic = ["version"]
16+
17+
[project.optional-dependencies]
18+
test = [
19+
"pytest",
20+
"pytest-asyncio",
21+
]
22+
23+
[project.scripts]
24+
jupyter-simple-ext1 = "simple_ext1.application:main"
25+
jupyter-simple-ext11 = "simple_ext11.application:main"
26+
jupyter-simple-ext2 = "simple_ext2.application:main"
27+
28+
[tool.hatch.version]
29+
source = "nodejs"
30+
31+
[tool.hatch.build.targets.wheel.shared-data]
32+
"etc/jupyter/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d"
33+
34+
[tool.hatch.build.hooks.jupyter-builder]
35+
dependencies = [
36+
"hatch-jupyter-builder>=0.8.2",
37+
]
38+
build-function = "hatch_jupyter_builder.npm_builder"

examples/simple/setup.py

+2-62
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,2 @@
1-
"""Example Jupyter Server setup."""
2-
import os
3-
4-
from jupyter_packaging import create_cmdclass # type:ignore
5-
from setuptools import setup
6-
7-
VERSION = "0.0.1"
8-
9-
10-
def get_data_files():
11-
"""Get the data files for the package."""
12-
data_files = [
13-
(
14-
"etc/jupyter/jupyter_server_config.d",
15-
"etc/jupyter/jupyter_server_config.d/",
16-
"*.json",
17-
),
18-
]
19-
20-
def add_data_files(path):
21-
for (dirpath, _, filenames) in os.walk(path):
22-
if filenames:
23-
paths = [(dirpath, dirpath, filename) for filename in filenames]
24-
data_files.extend(paths)
25-
26-
# Add all static and templates folders.
27-
add_data_files("simple_ext1/static")
28-
add_data_files("simple_ext1/templates")
29-
add_data_files("simple_ext2/static")
30-
add_data_files("simple_ext2/templates")
31-
return data_files
32-
33-
34-
cmdclass = create_cmdclass(data_files_spec=get_data_files())
35-
36-
setup_args = {
37-
"name": "jupyter_server_example",
38-
"version": VERSION,
39-
"description": "Jupyter Server Example",
40-
"long_description": open("README.md").read(),
41-
"python_requires": ">=3.8",
42-
"install_requires": [
43-
"jupyter_server",
44-
"jinja2",
45-
],
46-
"extras_require": {
47-
"test": ["pytest", "pytest-asyncio"],
48-
},
49-
"include_package_data": True,
50-
"cmdclass": cmdclass,
51-
"entry_points": {
52-
"console_scripts": [
53-
"jupyter-simple-ext1 = simple_ext1.application:main",
54-
"jupyter-simple-ext11 = simple_ext11.application:main",
55-
"jupyter-simple-ext2 = simple_ext2.application:main",
56-
]
57-
},
58-
}
59-
60-
61-
if __name__ == "__main__":
62-
setup(**setup_args)
1+
# setup.py shim for use with applications that require it.
2+
__import__("setuptools").setup()

examples/simple/simple_ext1/static/bundle.js

-144
This file was deleted.
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function main() {
2-
let div = document.getElementById("mydiv");
3-
div.innerText = "Hello from Typescript";
2+
let div = document.getElementById("mydiv");
3+
div.innerText = "Hello from Typescript";
44
}
55
window.addEventListener("load", main);

examples/simple/simple_ext1/static/tsconfig.tsbuildinfo

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"signature": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303"
5151
},
5252
"../../src/index.ts": {
53-
"version": "fd4f62325debd29128c1990caa4d546f2c48c21ea133fbcbb3e29f9fbef55e49",
53+
"version": "a5398b1577287a9a5a7e190a9a7283ee67b12fcc0dbc6d2cac55ef25ed166bb2",
5454
"signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896"
5555
}
5656
},

0 commit comments

Comments
 (0)