Skip to content

Commit 1a5daf7

Browse files
Migrate to hatch (#168)
* Migrate to `hatch` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Require Python 3.7 * Fix pyproject * Restore tbump config * Fix `dest` in `__init__.py` * Remove top-level version * Fix version * Fix hatch version * Add `artifacts` * Fix artifacts * Add ignore Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9789555 commit 1a5daf7

File tree

6 files changed

+122
-162
lines changed

6 files changed

+122
-162
lines changed

.flake8

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[flake8]
2+
max-line-length=200
3+
# Ignore style and complexity
4+
# E: style errors
5+
# W: style warnings
6+
# F401: module imported but unused
7+
# F811: redefinition of unused `name` from line `N`
8+
# F841: local variable assigned but never used
9+
ignore = E, C, W, F401, F403, F811, F841, E402, I100, I101, D400
10+
exclude =
11+
jupyter-resource-usage/tests,
12+
helm-chart,
13+
hooks,
14+
setup.py,
15+
statuspage,
16+
versioneer.py

MANIFEST.in

-25
This file was deleted.

jupyter_resource_usage/__init__.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import json
21
from pathlib import Path
32

43
from ._version import __version__
54
from .server_extension import load_jupyter_server_extension
65

7-
HERE = Path(__file__).parent.resolve()
8-
9-
data = json.loads((HERE / "labextension" / "package.json").read_text())
10-
116

127
def _jupyter_labextension_paths():
13-
return [{"src": "labextension", "dest": data["name"]}]
8+
return [{"src": "labextension", "dest": "@jupyter-server/resource-usage"}]
149

1510

1611
def _jupyter_server_extension_points():

pyproject.toml

+103-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,104 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.10", "jupyterlab~=3.0"]
3-
build-backend = "jupyter_packaging.build_api"
2+
requires = [
3+
"hatchling",
4+
"jupyterlab~=3.0",
5+
]
6+
build-backend = "hatchling.build"
47

5-
[license]
6-
file="LICENSE"
8+
[project]
9+
name = "jupyter-resource-usage"
10+
description = "Jupyter Extension to show resource usage"
11+
readme = "README.md"
12+
requires-python = ">=3.7"
13+
authors = [
14+
{ name = "Jupyter Development Team" },
15+
]
16+
keywords = [
17+
"IPython",
18+
"Jupyter",
19+
"JupyterLab",
20+
]
21+
classifiers = [
22+
"Framework :: Jupyter",
23+
"Framework :: Jupyter :: JupyterLab",
24+
"Framework :: Jupyter :: JupyterLab :: 3",
25+
"Framework :: Jupyter :: JupyterLab :: Extensions",
26+
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
27+
"Intended Audience :: Developers",
28+
"Intended Audience :: Science/Research",
29+
"License :: OSI Approved :: BSD License",
30+
"Programming Language :: Python",
31+
"Programming Language :: Python :: 3",
32+
"Programming Language :: Python :: 3.7",
33+
"Programming Language :: Python :: 3.8",
34+
"Programming Language :: Python :: 3.9",
35+
"Programming Language :: Python :: 3.10",
36+
"Programming Language :: Python :: 3.11",
37+
]
38+
dependencies = [
39+
"jupyter_server>=1.0",
40+
"prometheus_client",
41+
"psutil~=5.6",
42+
]
43+
dynamic = ["version"]
744

8-
[tool.jupyter-packaging.options]
9-
skip-if-exists = ["jupyter_resource_usage/labextension/static/style.js"]
10-
ensured-targets = ["jupyter_resource_usage/labextension/static/style.js", "jupyter_resource_usage/labextension/package.json"]
45+
[project.license]
46+
file = "LICENSE"
1147

12-
[tool.jupyter-packaging.builder]
13-
factory = "jupyter_packaging.npm_builder"
48+
[project.optional-dependencies]
49+
dev = [
50+
"autopep8",
51+
"black",
52+
"flake8",
53+
"mock",
54+
"pytest",
55+
"pytest-cov>=2.6.1",
56+
]
1457

15-
[tool.jupyter-packaging.build-args]
58+
[project.urls]
59+
Homepage = "https://github.com/jupyter-server/jupyter-resource-usage"
60+
61+
[tool.hatch.build.targets.wheel.shared-data]
62+
"jupyter_resource_usage/static" = "share/jupyter/nbextensions/jupyter_resource_usage"
63+
"jupyter_resource_usage/labextension/package.json" = "share/jupyter/labextensions/@jupyter-server/resource-usage/package.json"
64+
"jupyter_resource_usage/labextension/static" = "share/jupyter/labextensions/@jupyter-server/resource-usage/static"
65+
"install.json" = "share/jupyter/labextensions/@jupyter-server/resource-usage/install.json"
66+
"jupyter-config/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d"
67+
"jupyter-config/jupyter_notebook_config.d" = "etc/jupyter/jupyter_notebook_config.d"
68+
"jupyter-config/nbconfig/notebook.d" = "etc/jupyter/nbconfig/notebook.d"
69+
70+
[tool.hatch.version]
71+
path = "jupyter_resource_usage/_version.py"
72+
73+
[tool.hatch.build.targets.sdist]
74+
artifacts = ["jupyter_resource_usage/labextension"]
75+
exclude = [".github", "binder"]
76+
77+
[tool.hatch.build.hooks.jupyter-builder]
78+
dependencies = [
79+
"hatch-jupyter-builder>=0.8.2",
80+
]
81+
build-function = "hatch_jupyter_builder.npm_builder"
82+
ensured-targets = [
83+
"jupyter_resource_usage/labextension/static/style.js",
84+
"jupyter_resource_usage/labextension/package.json",
85+
]
86+
skip-if-exists = [
87+
"jupyter_resource_usage/labextension/static/style.js",
88+
]
89+
90+
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
91+
build_cmd = "build:prod"
92+
npm = [
93+
"jlpm",
94+
]
95+
force = true
96+
97+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
1698
build_cmd = "build:prod"
17-
npm = ["jlpm"]
99+
npm = [
100+
"jlpm",
101+
]
18102
source_dir = "packages/labextension"
19103
build_dir = "jupyter_resource_usage/labextension"
20104

@@ -44,7 +128,12 @@ name = "release"
44128
default = ""
45129

46130
[tool.jupyter-releaser.hooks]
47-
before-build-npm = ["python -m pip install jupyterlab~=3.0", "jlpm", "jlpm clean", "jlpm build:prod"]
131+
before-build-npm = [
132+
"python -m pip install jupyterlab~=3.0",
133+
"jlpm",
134+
"jlpm clean",
135+
"jlpm build:prod",
136+
]
48137

49-
[tool.check-manifest]
50-
ignore = ["binder/**", "packages/**", "*.json", "*.png", "yarn.lock", ".*", "jupyter_resource_usage/labextension/**", "jupyter_resource_usage/static/**"]
138+
[tool.check-wheel-contents]
139+
ignore = ["W002", "W004"]

setup.cfg

-63
This file was deleted.

setup.py

+2-54
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,2 @@
1-
from pathlib import Path
2-
3-
import setuptools
4-
5-
# The directory containing this file
6-
HERE = Path(__file__).parent.resolve()
7-
8-
# The name of the project
9-
NAME = "jupyter-resource-usage"
10-
PACKAGE_NAME = NAME.replace("-", "_")
11-
LABEXT_NAME = "@jupyter-server/resource-usage"
12-
NBEXT_NAME = "jupyter_resource_usage"
13-
14-
15-
lab_path = HERE / PACKAGE_NAME / "labextension"
16-
nb_path = HERE / PACKAGE_NAME / "static"
17-
src_path = HERE / "packages" / "labextension"
18-
19-
# Representative files that should exist after a successful build
20-
ensured_targets = [str(lab_path / "package.json"), str(lab_path / "static/style.js")]
21-
22-
data_files_spec = [
23-
("share/jupyter/nbextensions/%s" % NBEXT_NAME, nb_path, "**"),
24-
("share/jupyter/labextensions/%s" % LABEXT_NAME, lab_path, "**"),
25-
("share/jupyter/labextensions/%s" % LABEXT_NAME, HERE, "install.json"),
26-
(
27-
"etc/jupyter/jupyter_server_config.d",
28-
"jupyter-config/jupyter_server_config.d",
29-
"jupyter_resource_usage.json",
30-
),
31-
(
32-
"etc/jupyter/jupyter_notebook_config.d",
33-
"jupyter-config/jupyter_notebook_config.d",
34-
"jupyter_resource_usage.json",
35-
),
36-
(
37-
"etc/jupyter/nbconfig/notebook.d",
38-
"jupyter-config/nbconfig/notebook.d",
39-
"jupyter_resource_usage.json",
40-
),
41-
]
42-
43-
try:
44-
from jupyter_packaging import wrap_installers, npm_builder, get_data_files
45-
46-
builder = npm_builder(build_cmd="build:prod", npm="jlpm", force=True)
47-
cmdclass = wrap_installers(post_develop=builder, ensured_targets=ensured_targets)
48-
setup_args = dict(cmdclass=cmdclass, data_files=get_data_files(data_files_spec))
49-
except ImportError:
50-
setup_args = dict()
51-
52-
53-
if __name__ == "__main__":
54-
setuptools.setup(**setup_args)
1+
# setup.py shim for use with applications that require it.
2+
__import__("setuptools").setup()

0 commit comments

Comments
 (0)