diff --git a/.gitignore b/.gitignore index 9adfd4d..8cdaa83 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,5 @@ ui-tests/test-results/* ui-tests/playwright-report/* .yarn + +bqplot_gl/_version.py diff --git a/bqplot_gl/_version.py b/bqplot_gl/_version.py deleted file mode 100644 index b07aeaa..0000000 --- a/bqplot_gl/_version.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) The bqplot Development Team. -# Distributed under the terms of the Modified BSD License. - -__version__ = "0.1.0a0" diff --git a/pyproject.toml b/pyproject.toml index ec1f0b3..0796c40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,9 @@ [build-system] requires = [ + "hatch", "hatchling", + "hatch-nodejs-version", + "hatch-build-scripts", "jupyterlab==4.*", ] build-backend = "hatchling.build" @@ -28,16 +31,19 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] dependencies = [ "bqplot>=0.13.0a0,<0.14", ] -version = "0.1.0a0" +dynamic = [ + "version", +] [project.license] file = "LICENSE" @@ -45,10 +51,14 @@ file = "LICENSE" [project.urls] Homepage = "https://github.com/bqplot/bqplot-gl" +[tool.hatch.version] +source = "nodejs" + [tool.hatch.build] artifacts = [ "bqplot_gl/nbextension/index.*", "bqplot_gl/labextension", + "bqplot_gl/_version.py", ] [tool.hatch.build.targets.wheel.shared-data] @@ -71,34 +81,16 @@ dependencies = [ ] build-function = "hatch_jupyter_builder.npm_builder" +[[tool.hatch.build.hooks.build-scripts.scripts]] +work_dir = "." +commands = ['python scripts/write_version.py'] +artifacts = [ + "bqplot_gl/_version.py" +] + [tool.hatch.build.hooks.jupyter-builder.build-kwargs] path = "." build_cmd = "build:prod" npm = [ "jlpm", ] - -[tool.tbump] -field = [ - { name = "channel", default = "" }, - { name = "release", default = "" }, -] - -[tool.tbump.version] -current = "0.1.0a0" -regex = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)((?Pa|b|rc|.dev)(?P\\d+))?" - -[tool.tbump.git] -message_template = "Bump to {new_version}" -tag_template = "v{new_version}" - -[[tool.tbump.file]] -src = "pyproject.toml" -version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\"" - -[[tool.tbump.file]] -src = "bqplot_gl/_version.py" - -[[tool.tbump.file]] -src = "package.json" -version_template = "\"version\": \"{major}.{minor}.{patch}{channel}{release}\"" diff --git a/scripts/write_version.py b/scripts/write_version.py new file mode 100644 index 0000000..229fb31 --- /dev/null +++ b/scripts/write_version.py @@ -0,0 +1,15 @@ +import json, pathlib + + +pkg = pathlib.Path('bqplot_gl') +pkg.mkdir(exist_ok=True) + +with open('package.json') as f: + version = json.load(f)['version'] + +with open(pkg / '_version.py', 'w') as f: + f.write( + '# Auto-generated from package.json\n' + '\n' + f'__version__ = "{version}"\n' + )