Skip to content

Commit 895a380

Browse files
authored
Switch to using hatchling version command (#984)
* switch to using hatchling version * revert changes to package-lock
1 parent a99119e commit 895a380

File tree

4 files changed

+25
-38
lines changed

4 files changed

+25
-38
lines changed

RELEASE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To create a manual release, perform the following steps:
1414
### Set up
1515

1616
```bash
17-
pip install tbump twine build
17+
pip install hatchling twine build
1818
git pull origin $(git branch --show-current)
1919
git clean -dffx
2020
npm install
@@ -26,7 +26,8 @@ npm run build
2626
```bash
2727
echo "Enter new version"
2828
read script_version
29-
tbump ${script_version}
29+
hachling version ${script_version}
30+
git tag -a ${script_version} -m "Release ${script_version}"
3031
```
3132

3233
### Build the artifacts
@@ -41,7 +42,7 @@ python -m build .
4142
```bash
4243
echo "Enter dev version"
4344
read dev_version
44-
tbump ${dev_version} --no-tag
45+
hatchling ${dev_version}
4546
git push origin $(git branch --show-current)
4647
```
4748

docs/source/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os.path as osp
1616
import shutil
1717
import sys
18+
from importlib.metadata import version
1819

1920
from packaging.version import parse as parse_version
2021

@@ -108,10 +109,10 @@
108109
# |version| and |release|, also used in various other places throughout the
109110
# built documents.
110111
#
111-
__version__ = "2.1.0.dev0"
112+
__version__ = version("jupyter_server")
112113
# The short X.Y version.
113114
version_parsed = parse_version(__version__)
114-
version = f"{version_parsed.major}.{version_parsed.minor}"
115+
version = f"{version_parsed.major}.{version_parsed.minor}" # type:ignore[assignment]
115116

116117
# The language for content autogenerated by Sphinx. Refer to documentation
117118
# for a list of supported languages.

jupyter_server/_version.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,17 @@
22
store the current version info of the server.
33
44
"""
5-
version_info = (2, 1, 0, ".dev", "0")
6-
__version__ = ".".join(map(str, version_info[:3])) + "".join(version_info[3:])
5+
import re
6+
from typing import List
7+
8+
# Version string must appear intact for tbump versioning
9+
__version__ = "2.1.0.dev0"
10+
11+
# Build up version_info tuple for backwards compatibility
12+
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
13+
match = re.match(pattern, __version__)
14+
assert match is not None
15+
parts: List[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
16+
if match["rest"]:
17+
parts.append(match["rest"])
18+
version_info = tuple(parts)

pyproject.toml

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

55
[project]
66
name = "jupyter_server"
7-
version = "2.1.0.dev0"
7+
dynamic = ["version"]
88
readme = "README.md"
99
license = { file = "COPYING.md" }
1010
description = "The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications."
@@ -72,6 +72,9 @@ dev = [
7272
[project.scripts]
7373
jupyter-server = "jupyter_server.serverapp:main"
7474

75+
[tool.hatch.version]
76+
path = "jupyter_server/_version.py"
77+
7578
[tool.hatch.build]
7679
artifacts = ["jupyter_server/static/style"]
7780

@@ -119,36 +122,6 @@ before-build-python = ["npm install", "npm run build"]
119122
post-version-spec = "dev"
120123
pydist_resource_paths = ["jupyter_server/static/style/bootstrap.min.css", "jupyter_server/static/style/bootstrap-theme.min.css"]
121124

122-
[tool.tbump.version]
123-
current = "2.1.0.dev0"
124-
regex = '''
125-
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
126-
((?P<channel>a|b|rc|.dev)(?P<release>\d+))?
127-
'''
128-
129-
[tool.tbump.git]
130-
message_template = "Bump to {new_version}"
131-
tag_template = "v{new_version}"
132-
133-
[[tool.tbump.file]]
134-
src = "jupyter_server/_version.py"
135-
version_template = '({major}, {minor}, {patch}, "{channel}", "{release}")'
136-
137-
[[tool.tbump.file]]
138-
src = "pyproject.toml"
139-
version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\""
140-
141-
[[tool.tbump.file]]
142-
src = "docs/source/conf.py"
143-
version_template = "{major}.{minor}.{patch}{channel}{release}"
144-
145-
[[tool.tbump.field]]
146-
name = "channel"
147-
default = ""
148-
149-
[[tool.tbump.field]]
150-
name = "release"
151-
default = ""
152125

153126
[tool.mypy]
154127
check_untyped_defs = true

0 commit comments

Comments
 (0)