Skip to content

Commit 4634184

Browse files
authored
Use "hatchling version" as a version command where applicable (#374)
1 parent 2cd3e74 commit 4634184

File tree

3 files changed

+12
-34
lines changed

3 files changed

+12
-34
lines changed

docs/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# import os
1212
# import sys
1313
# sys.path.insert(0, os.path.abspath('.'))
14+
import importlib.metadata
1415
import os.path as osp
1516
import shutil
1617

@@ -23,7 +24,7 @@
2324
author = "Project Jupyter"
2425

2526
# The full version, including alpha/beta/rc tags.
26-
release = "0.23.3"
27+
release = importlib.metadata.version("jupyter_releaser")
2728
# The short X.Y version.
2829
version = ".".join(release.split(".")[:2])
2930

jupyter_releaser/util.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ def bump_version(version_spec, *, changelog_path="", version_cmd=""):
247247
version_cmd = version_cmd or TBUMP_CMD
248248

249249
if PYPROJECT.exists():
250-
if "tbump" in PYPROJECT.read_text(encoding="utf-8"):
250+
pyproject_text = PYPROJECT.read_text(encoding="utf-8")
251+
if "tool.tbump" in pyproject_text:
251252
version_cmd = version_cmd or TBUMP_CMD
253+
elif "hatchling.build" in pyproject_text:
254+
version_cmd = version_cmd or "hatchling version"
252255

253256
if SETUP_CFG.exists():
254257
if "bumpversion" in SETUP_CFG.read_text(encoding="utf-8"):
@@ -262,13 +265,13 @@ def bump_version(version_spec, *, changelog_path="", version_cmd=""):
262265

263266
# Assign default values if no version spec was given
264267
if not version_spec:
265-
if "tbump" in version_cmd:
268+
if "tbump" in version_cmd or "hatchling" in version_cmd:
266269
version_spec = "next"
267270
else:
268271
version_spec = "patch"
269272

270-
# Add some convenience options on top of "tbump"
271-
if "tbump" in version_cmd:
273+
# Add some convenience options on top of "tbump" and "hatch"
274+
if "tbump" in version_cmd or "hatchling" in version_cmd:
272275
v = parse_version(get_version())
273276
assert isinstance(v, Version)
274277

pyproject.toml

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "jupyter_releaser"
7-
version = "0.23.3"
87
description = "Jupyter Releaser for Python and/or npm packages."
98
license = {file = "LICENSE"}
109
authors = [{name = "Jupyter Development Team", email = "[email protected]"}]
@@ -21,6 +20,7 @@ classifiers = [
2120
]
2221
urls = {Homepage = "https://jupyter.org"}
2322
requires-python = ">=3.8"
23+
dynamic = ["version"]
2424
dependencies = [
2525
"build",
2626
"check-manifest",
@@ -59,34 +59,8 @@ test = [
5959
[project.scripts]
6060
jupyter-releaser = "jupyter_releaser.cli:main"
6161

62-
[tool.tbump.version]
63-
current = "0.23.3"
64-
regex = '''
65-
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
66-
((?P<channel>a|b|rc|.dev)(?P<release>\d+))?
67-
'''
68-
69-
[tool.tbump.git]
70-
message_template = "Bump to {new_version}"
71-
tag_template = "v{new_version}"
72-
73-
[[tool.tbump.file]]
74-
src = "jupyter_releaser/__init__.py"
75-
76-
[[tool.tbump.file]]
77-
src = "pyproject.toml"
78-
version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\""
79-
80-
[[tool.tbump.file]]
81-
src = "docs/source/conf.py"
82-
83-
[[tool.tbump.field]]
84-
name = "channel"
85-
default = ""
86-
87-
[[tool.tbump.field]]
88-
name = "release"
89-
default = ""
62+
[tool.hatch.version]
63+
path = "jupyter_releaser/__init__.py"
9064

9165
[tool.jupyter-releaser]
9266
skip = ["check-links"]

0 commit comments

Comments
 (0)