Skip to content

Commit dcc3ed3

Browse files
committed
Switch to hatch backend
1 parent f9c668a commit dcc3ed3

File tree

6 files changed

+55
-96
lines changed

6 files changed

+55
-96
lines changed

buildapi.py

-79
This file was deleted.

hatch_build.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Custom build script for hatch backend"""
2+
import glob
3+
import os
4+
import subprocess
5+
6+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
7+
8+
9+
class CustomHook(BuildHookInterface):
10+
def initialize(self, version, build_data):
11+
cmd = "build:prod" if version == "stable" else "build"
12+
osp = os.path
13+
here = osp.abspath(osp.dirname(__file__))
14+
lab_path = osp.join(here, 'ipyparallel', 'labextension')
15+
16+
if os.environ.get("IPP_DISABLE_JS") == "1":
17+
print("Skipping js installation")
18+
return
19+
20+
# this tells us if labextension is built at all, not if it's up-to-date
21+
labextension_built = glob.glob(osp.join(lab_path, "*"))
22+
needs_js = True
23+
if not osp.isdir(osp.join(here, ".git")):
24+
print("Installing from a dist, not a repo")
25+
# not in a repo, probably installing from sdist
26+
# could be git-archive, though!
27+
# skip rebuilding js if it's already present
28+
if labextension_built:
29+
print(f"Not regenerating labextension in {lab_path}")
30+
needs_js = False
31+
32+
if needs_js:
33+
subprocess.check_call(['jlpm'], cwd=here)
34+
subprocess.check_call(['jlpm', 'run', cmd], cwd=here)

pyproject.toml

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[build-system]
22
requires = [
33
"jupyterlab>=3.0.0,==3.*",
4-
"flit_core >=3.2,<4"
4+
"hatchling"
55
]
6-
build-backend = "buildapi"
7-
backend-path = ["."]
6+
build-backend = "hatchling.build"
87

98
[project]
109
name = "ipyparallel"
10+
version = "8.4.0.dev"
1111
authors = [{name = "IPython Development Team", email = "[email protected]"}]
1212
license = {file = "COPYING.md"}
1313
readme = "README.md"
@@ -48,7 +48,6 @@ dependencies = [
4848
"python-dateutil>=2.1",
4949
"tqdm",
5050
]
51-
dynamic = ["version"]
5251

5352
[project.entry-points."ipyparallel.controller_launchers"]
5453
batch = "ipyparallel.cluster.launcher:BatchControllerLauncher"
@@ -95,20 +94,22 @@ ipcluster = "ipyparallel.cluster.app:main"
9594
ipcontroller = "ipyparallel.controller.app:main"
9695
ipengine = "ipyparallel.engine.app:main"
9796

98-
[tool.flit.sdist]
99-
include = [
100-
"benchmarks/",
101-
"docs/",
102-
"*.json",
103-
"yarn.lock",
104-
"jupyter-data/",
105-
"lab/",
106-
"buildapi.py",
97+
# Used to call hatch_build.py
98+
[tool.hatch.build.targets.wheel.hooks.custom]
99+
[tool.hatch.build.targets.sdist.hooks.custom]
100+
101+
[tool.hatch.build]
102+
artifacts = [
103+
"ipyparallel/**/*.*"
104+
]
105+
exclude = [
106+
"lab/lib"
107107
]
108-
exclude = ["lab/lib/"]
109108

110-
[tool.flit.external-data]
111-
directory = "jupyter-data"
109+
[tool.hatch.build.targets.wheel.shared-data]
110+
"jupyter-config" = "etc/jupyter"
111+
"ipyparallel/nbextension/static" = "share/jupyter/nbextensions/ipyparallel"
112+
"ipyparallel/labextension" = "share/jupyter/labextensions/ipyparallel-labextension"
112113

113114
[tool.black]
114115
skip-string-normalization = true
@@ -139,7 +140,6 @@ filterwarnings = [
139140
"ignore:the imp module is:DeprecationWarning",
140141
]
141142

142-
143143
[tool.tbump]
144144
# Uncomment this if your project is hosted on GitHub:
145145
github_url = "https://github.com/jupyterhub/jupyterhub"
@@ -172,6 +172,10 @@ tag_template = "{new_version}"
172172
src = "ipyparallel/_version.py"
173173
search = '__version__ = "{current_version}"'
174174

175+
[[tool.tbump.file]]
176+
src = "pyproject.toml"
177+
search = '"version" = "{current_version}"'
178+
175179
[[tool.tbump.file]]
176180
src = "package.json"
177181
search = '"version": "{current_version}"'

0 commit comments

Comments
 (0)