Skip to content

Commit 85a2874

Browse files
authored
Dynamic version from JS (#24)
* Dynamic version from JS * Add gitignore * Missing artifact * Wrong copy paste + unused config
1 parent 0ec402b commit 85a2874

File tree

4 files changed

+37
-35
lines changed

4 files changed

+37
-35
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,5 @@ ui-tests/test-results/*
160160
ui-tests/playwright-report/*
161161

162162
.yarn
163+
164+
bqplot_gl/_version.py

bqplot_gl/_version.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

pyproject.toml

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[build-system]
22
requires = [
3+
"hatch",
34
"hatchling",
5+
"hatch-nodejs-version",
6+
"hatch-build-scripts",
47
"jupyterlab==4.*",
58
]
69
build-backend = "hatchling.build"
@@ -28,27 +31,34 @@ classifiers = [
2831
"License :: OSI Approved :: Apache Software License",
2932
"Programming Language :: Python",
3033
"Programming Language :: Python :: 3",
31-
"Programming Language :: Python :: 3.7",
32-
"Programming Language :: Python :: 3.8",
3334
"Programming Language :: Python :: 3.9",
3435
"Programming Language :: Python :: 3.10",
3536
"Programming Language :: Python :: 3.11",
37+
"Programming Language :: Python :: 3.12",
38+
"Programming Language :: Python :: 3.13",
39+
"Programming Language :: Python :: 3.14",
3640
]
3741
dependencies = [
3842
"bqplot>=0.13.0a0,<0.14",
3943
]
40-
version = "0.1.0a0"
44+
dynamic = [
45+
"version",
46+
]
4147

4248
[project.license]
4349
file = "LICENSE"
4450

4551
[project.urls]
4652
Homepage = "https://github.com/bqplot/bqplot-gl"
4753

54+
[tool.hatch.version]
55+
source = "nodejs"
56+
4857
[tool.hatch.build]
4958
artifacts = [
5059
"bqplot_gl/nbextension/index.*",
5160
"bqplot_gl/labextension",
61+
"bqplot_gl/_version.py",
5262
]
5363

5464
[tool.hatch.build.targets.wheel.shared-data]
@@ -71,34 +81,16 @@ dependencies = [
7181
]
7282
build-function = "hatch_jupyter_builder.npm_builder"
7383

84+
[[tool.hatch.build.hooks.build-scripts.scripts]]
85+
work_dir = "."
86+
commands = ['python scripts/write_version.py']
87+
artifacts = [
88+
"bqplot_gl/_version.py"
89+
]
90+
7491
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
7592
path = "."
7693
build_cmd = "build:prod"
7794
npm = [
7895
"jlpm",
7996
]
80-
81-
[tool.tbump]
82-
field = [
83-
{ name = "channel", default = "" },
84-
{ name = "release", default = "" },
85-
]
86-
87-
[tool.tbump.version]
88-
current = "0.1.0a0"
89-
regex = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)((?P<channel>a|b|rc|.dev)(?P<release>\\d+))?"
90-
91-
[tool.tbump.git]
92-
message_template = "Bump to {new_version}"
93-
tag_template = "v{new_version}"
94-
95-
[[tool.tbump.file]]
96-
src = "pyproject.toml"
97-
version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\""
98-
99-
[[tool.tbump.file]]
100-
src = "bqplot_gl/_version.py"
101-
102-
[[tool.tbump.file]]
103-
src = "package.json"
104-
version_template = "\"version\": \"{major}.{minor}.{patch}{channel}{release}\""

scripts/write_version.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import json, pathlib
2+
3+
4+
pkg = pathlib.Path('bqplot_gl')
5+
pkg.mkdir(exist_ok=True)
6+
7+
with open('package.json') as f:
8+
version = json.load(f)['version']
9+
10+
with open(pkg / '_version.py', 'w') as f:
11+
f.write(
12+
'# Auto-generated from package.json\n'
13+
'\n'
14+
f'__version__ = "{version}"\n'
15+
)

0 commit comments

Comments
 (0)