Skip to content

Commit ca3e547

Browse files
authored
Introduce uv-dynamic-versioning (#1023)
1 parent afa111a commit ca3e547

File tree

4 files changed

+251
-36
lines changed

4 files changed

+251
-36
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@ jobs:
5454
run: |
5555
uv sync --no-default-groups
5656
57-
- name: Make sure pyproject.toml version matches git version
58-
run: |
59-
git_version=$(git describe)
60-
git_version="${git_version:1}" # first character is always `v`
61-
pyproject_version=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
62-
63-
if [ "$git_version" != "$pyproject_version" ]; then
64-
echo "The version specified in pyproject.toml ($pyproject_version) doesn't match the git version ($git_verson)"
65-
echo "You most likely forgot to update pyproject.toml when publishing the release tag"
66-
echo "You can fix this by updating the pyproject version and overwriting the git tag"
67-
exit 1
68-
fi
69-
7057
- name: Build package
7158
run: uv build
7259

docs/conf.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,26 @@
1515

1616
import os
1717
import sys
18-
from datetime import date
19-
from typing import TYPE_CHECKING
2018

21-
from packaging.version import parse as parse_version
19+
from packaging.version import Version, parse as parse_version
20+
from importlib.metadata import version as importlib_version
2221

23-
# Since pyright assumes lowest supported version, it would default to using tomli
24-
# which we don't want, as it's only installed if on <3.11 and pyright usually runs
25-
# on latest versions. For that reason, we include or TYPE_CHECKING in the condition.
26-
if sys.version_info >= (3, 11) or TYPE_CHECKING:
27-
from tomllib import load as toml_parse
28-
else:
29-
from tomli import load as toml_parse
3022

3123
sys.path.insert(0, os.path.abspath(".."))
3224

3325

3426
# -- Project information -----------------------------------------------------
3527

3628

37-
def _get_project_meta() -> dict[str, str]:
38-
with open("../pyproject.toml", "rb") as pyproject:
39-
return toml_parse(pyproject)["project"] # type: ignore[no-any-return]
29+
def _get_version() -> Version:
30+
return parse_version(importlib_version("mcstatus"))
4031

4132

42-
pkg_meta = _get_project_meta()
43-
project = str(pkg_meta["name"])
44-
copyright = str(date.today().year) + ", py-mine"
33+
project = "mcstatus"
34+
copyright = "mcstatus, py-mine"
4535
author = "Dinnerbone"
4636

47-
parsed_version = parse_version(pkg_meta["version"])
37+
parsed_version = _get_version()
4838

4939
# The short X.Y version
5040
version = parsed_version.base_version

pyproject.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mcstatus"
3-
version = "12.0.2"
3+
dynamic = ["version"]
44
license = "Apache-2.0"
55
description = "A library to query Minecraft Servers for their status and capabilities."
66
readme = "README.md"
@@ -67,6 +67,10 @@ docs = [
6767
"tomli>=2.0.1; python_version < '3.11'",
6868
"packaging>=24.2",
6969
"docutils>=0.18.1,<0.21", # temporary fix for https://github.com/CrossNox/m2r2/issues/68
70+
"uv-dynamic-versioning", # actual version is in `release` group
71+
]
72+
release = [
73+
"uv-dynamic-versioning>=0.8.2",
7074
]
7175

7276
[tool.poe.tasks]
@@ -186,9 +190,12 @@ split-on-trailing-comma = false # if last member of multiline import has a comma
186190
[tool.ruff-formatter]
187191
line-ending = "lf"
188192

193+
[project.scripts]
194+
mcstatus = "mcstatus.__main__:main"
195+
189196
[build-system]
190-
requires = ["hatchling"]
197+
requires = ["hatchling", "uv-dynamic-versioning"]
191198
build-backend = "hatchling.build"
192199

193-
[project.scripts]
194-
mcstatus = "mcstatus.__main__:main"
200+
[tool.hatch.version]
201+
source = "uv-dynamic-versioning"

0 commit comments

Comments
 (0)