Skip to content

Commit 43cbf4f

Browse files
authored
Better versionning handling (#379)
* Better versionning handling * Oups * More * Remove check release
1 parent ae7e206 commit 43cbf4f

File tree

6 files changed

+42
-82
lines changed

6 files changed

+42
-82
lines changed

.github/workflows/check-release.yml

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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,5 @@ python_data.data
170170
# UI tests
171171
ui-tests/tests/notebooks/smoke_texture0.png
172172
ui-tests/tests/notebooks/smoke_texture1.png
173+
174+
ipycanvas/_version.py

ipycanvas/_frontend.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
Information about the frontend package of the widgets.
99
"""
1010

11+
from ._version import __version__
12+
13+
major, minor, patch = __version__.split('.')
14+
1115
module_name = "ipycanvas"
12-
module_version = "^0.14"
16+
module_version = f"^{major}.{minor}"

ipycanvas/_version.py

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

pyproject.toml

Lines changed: 20 additions & 41 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>=3,<5",
58
]
69
build-backend = "hatchling.build"
@@ -16,6 +19,7 @@ keywords = [
1619
"IPython",
1720
"Jupyter",
1821
"Widgets",
22+
"Canvas",
1923
]
2024
classifiers = [
2125
"Framework :: Jupyter",
@@ -24,18 +28,21 @@ classifiers = [
2428
"License :: OSI Approved :: BSD License",
2529
"Programming Language :: Python",
2630
"Programming Language :: Python :: 3",
27-
"Programming Language :: Python :: 3.8",
2831
"Programming Language :: Python :: 3.9",
2932
"Programming Language :: Python :: 3.10",
3033
"Programming Language :: Python :: 3.11",
3134
"Programming Language :: Python :: 3.12",
35+
"Programming Language :: Python :: 3.13",
36+
"Programming Language :: Python :: 3.14",
3237
]
3338
dependencies = [
3439
"ipywidgets>=7.6.0,<9",
3540
"numpy",
3641
"pillow>=6.0",
3742
]
38-
version = "0.14.2"
43+
dynamic = [
44+
"version",
45+
]
3946

4047
[project.license]
4148
file = "LICENSE.txt"
@@ -45,10 +52,14 @@ file = "LICENSE.txt"
4552
[project.urls]
4653
Homepage = "https://github.com/jupyter-widgets-contrib/ipycanvas"
4754

55+
[tool.hatch.version]
56+
source = "nodejs"
57+
4858
[tool.hatch.build]
4959
artifacts = [
5060
"ipycanvas/nbextension/static/index.*",
5161
"ipycanvas/labextension",
62+
"ipycanvas/_version.py",
5263
]
5364

5465
[tool.hatch.build.targets.wheel.shared-data]
@@ -59,6 +70,7 @@ artifacts = [
5970
[tool.hatch.build.targets.sdist]
6071
exclude = [
6172
".github",
73+
"ipycanvas/_version.py",
6274
]
6375

6476
[tool.hatch.build.hooks.jupyter-builder]
@@ -72,51 +84,18 @@ dependencies = [
7284
]
7385
build-function = "hatch_jupyter_builder.npm_builder"
7486

87+
[[tool.hatch.build.hooks.build-scripts.scripts]]
88+
work_dir = "."
89+
commands = ['python scripts/write_version.py']
90+
# _version.py is already mentioned in top-level build artifact
91+
artifacts = []
92+
7593
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
7694
path = "."
7795
build_cmd = "build:extensions"
7896
npm = [
7997
"yarn",
8098
]
8199

82-
[tool.tbump]
83-
field = [
84-
{ name = "channel", default = "" },
85-
{ name = "release", default = "" },
86-
]
87-
88-
[tool.tbump.version]
89-
current = "0.14.2"
90-
regex = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)((?P<channel>a|b|rc|.dev)(?P<release>\\d+))?"
91-
92-
[tool.tbump.git]
93-
message_template = "Bump to {new_version}"
94-
tag_template = "v{new_version}"
95-
96-
[[tool.tbump.file]]
97-
src = "pyproject.toml"
98-
version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\""
99-
100-
[[tool.tbump.file]]
101-
src = "ipycanvas/_version.py"
102-
103-
[[tool.tbump.file]]
104-
src = "package.json"
105-
version_template = "\"version\": \"{major}.{minor}.{patch}{channel}{release}\""
106-
107-
[tool.jupyter-releaser.hooks]
108-
before-bump-version = [
109-
"python -m pip install hatch jupyterlab~=4.0",
110-
]
111-
before-build-npm = [
112-
"python -m pip install jupyterlab~=4.0",
113-
"jlpm",
114-
"jlpm clean",
115-
"jlpm build",
116-
]
117-
before-build-python = [
118-
"jlpm clean",
119-
]
120-
121100
[tool.check-wheel-contents]
122101
ignore = ["W002"]

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('ipycanvas')
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)