Skip to content

Commit c31091b

Browse files
committed
Change project to use hatch
1 parent af51bd6 commit c31091b

File tree

2 files changed

+63
-106
lines changed

2 files changed

+63
-106
lines changed

pyproject.toml

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,74 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.4"]
3-
build-backend = "jupyter_packaging.build_api"
2+
requires = ["hatchling>=1.9.0", "hatch-nodejs-version", "jupyterlab~=3.4"]
3+
build-backend = "hatchling.build"
44

5-
[tool.jupyter-packaging.options]
6-
skip-if-exists = ["jupyterlab_lego_boost/labextension/static/style.js"]
7-
ensured-targets = ["jupyterlab_lego_boost/labextension/static/style.js", "jupyterlab_lego_boost/labextension/package.json"]
5+
[project]
6+
name = "jupyterlab-lego-boost"
7+
readme = "README.md"
8+
requires-python = ">=3.7"
9+
dependencies = ['jupyterlab-blockly>=0.2.1,<0.3']
10+
classifiers = [
11+
"License :: OSI Approved :: BSD License",
12+
"Programming Language :: Python",
13+
"Programming Language :: Python :: 3",
14+
"Programming Language :: Python :: 3.7",
15+
"Programming Language :: Python :: 3.8",
16+
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.10",
18+
"Framework :: Jupyter",
19+
"Framework :: Jupyter :: JupyterLab",
20+
"Framework :: Jupyter :: JupyterLab :: 3",
21+
"Framework :: Jupyter :: JupyterLab :: Extensions",
22+
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
23+
]
24+
dynamic = ["version", "description", "authors", "urls", "keywords"]
25+
26+
[project.license]
27+
file = "LICENSE"
28+
29+
[project.optional-dependencies]
30+
env = ["bleak", "pylgbst"]
31+
32+
33+
[tool.hatch.version]
34+
source = "nodejs"
35+
36+
[tool.hatch.metadata.hooks.nodejs]
37+
fields = ["description", "authors", "urls"]
38+
39+
[tool.hatch.build]
40+
ignore-vcs = true
41+
42+
[tool.hatch.build.targets.wheel.shared-data]
43+
"install.json" = "share/jupyter/labextensions/jupyterlab-lego-boost/install.json"
44+
"jupyterlab_lego_boost/labextension" = "share/jupyter/labextensions/jupyterlab-lego-boost/"
845

9-
[tool.jupyter-packaging.builder]
10-
factory = "jupyter_packaging.npm_builder"
1146

12-
[tool.jupyter-packaging.build-args]
47+
[tool.hatch.build.hooks.jupyter-builder]
48+
dependencies = ["hatch-jupyter-builder>=0.6.2"]
49+
build-function = "hatch_jupyter_builder.npm_builder"
50+
ensured-targets = ["jupyterlab_lego_boost/labextension/static/style.js", "jupyterlab_lego_boost/labextension/package.json"]
51+
skip-if-exists = ["jupyterlab_lego_boost/labextension/static/style.js"]
52+
53+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
1354
build_cmd = "build:prod"
1455
npm = ["jlpm"]
1556

57+
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
58+
build_cmd = "install:extension"
59+
npm = ["jlpm"]
60+
61+
1662
[tool.check-manifest]
1763
ignore = ["jupyterlab_lego_boost/labextension/**", "yarn.lock", ".*", "package-lock.json"]
1864

65+
66+
#[tool.jupyter-releaser]
67+
#skip = ["check-links"]
68+
69+
[tool.jupyter-releaser.options]
70+
version_cmd = "hatch version"
71+
1972
[tool.jupyter-releaser.hooks]
2073
before-build-npm = ["python -m pip install jupyterlab~=3.4", "jlpm"]
2174
before-build-python = ["jlpm clean:all"]

setup.py

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,2 @@
1-
"""
2-
jupyterlab_lego_boost 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-
# Get the package info from package.json
13-
pkg_json = json.loads((HERE / "package.json").read_bytes())
14-
15-
# The name of the project
16-
name = "jupyterlab_lego_boost"
17-
18-
lab_path = (HERE / pkg_json["jupyterlab"]["outputDir"])
19-
20-
# Representative files that should exist after a successful build
21-
ensured_targets = [
22-
str(lab_path / "package.json"),
23-
str(lab_path / "static/style.js")
24-
]
25-
26-
labext_name = pkg_json["name"]
27-
28-
data_files_spec = [
29-
("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"),
30-
("share/jupyter/labextensions/%s" % labext_name, str("."), "install.json"),
31-
]
32-
33-
long_description = (HERE / "README.md").read_text(encoding="utf8")
34-
35-
version = (
36-
pkg_json["version"]
37-
.replace("-alpha.", "a")
38-
.replace("-beta.", "b")
39-
.replace("-rc.", "rc")
40-
)
41-
42-
setup_args = dict(
43-
name=name,
44-
version=version,
45-
url=pkg_json["homepage"],
46-
author=pkg_json["author"]["name"],
47-
author_email=pkg_json["author"]["email"],
48-
description=pkg_json["description"],
49-
license=pkg_json["license"],
50-
license_file="LICENSE",
51-
long_description=long_description,
52-
long_description_content_type="text/markdown",
53-
packages=setuptools.find_packages(),
54-
zip_safe=False,
55-
include_package_data=True,
56-
python_requires=">=3.7",
57-
install_requires=['jupyterlab-blockly>=0.2.1,<0.3'],
58-
extras_require={
59-
'env': ['bleak', 'pylgbst']
60-
},
61-
platforms="Linux, Mac OS X, Windows",
62-
keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
63-
classifiers=[
64-
"License :: OSI Approved :: BSD License",
65-
"Programming Language :: Python",
66-
"Programming Language :: Python :: 3",
67-
"Programming Language :: Python :: 3.7",
68-
"Programming Language :: Python :: 3.8",
69-
"Programming Language :: Python :: 3.9",
70-
"Programming Language :: Python :: 3.10",
71-
"Framework :: Jupyter",
72-
"Framework :: Jupyter :: JupyterLab",
73-
"Framework :: Jupyter :: JupyterLab :: 3",
74-
"Framework :: Jupyter :: JupyterLab :: Extensions",
75-
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
76-
],
77-
)
78-
79-
try:
80-
from jupyter_packaging import (
81-
wrap_installers,
82-
npm_builder,
83-
get_data_files
84-
)
85-
post_develop = npm_builder(
86-
build_cmd="install:extension", source_dir="src", build_dir=lab_path, force=True
87-
)
88-
setup_args["cmdclass"] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)
89-
setup_args["data_files"] = get_data_files(data_files_spec)
90-
except ImportError as e:
91-
import logging
92-
logging.basicConfig(format="%(levelname)s: %(message)s")
93-
logging.warning("Build tool `jupyter-packaging` is missing. Install it with pip or conda.")
94-
if not ("--name" in sys.argv or "--version" in sys.argv):
95-
raise e
96-
97-
if __name__ == "__main__":
98-
setuptools.setup(**setup_args)
1+
# setup.py shim for use with applications that require it.
2+
__import__("setuptools").setup()

0 commit comments

Comments
 (0)