Skip to content

Commit 9cc7760

Browse files
authored
Set version to 0.15.0.dev0, improve maintenance scripts (#524)
* Set version to 0.14.0 * Add versions to Cargo path dependencies * version scripts: also bump up Cargo path dependencies * Merge the almost-identical version bumping scripts * Set version to 0.15.0.dev0, improve maintenance scripts - Merge the dev/release version bump scripts into one. - Make the script handle Cargo path dependency versions. * Fix variables
1 parent 5589b90 commit 9cc7760

13 files changed

Lines changed: 293 additions & 240 deletions

File tree

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: style kernel-builder-cli-docs quality bump-dev bump-dev-dry-run pre-release pre-release-dry-run pin-actions
1+
.PHONY: style kernel-builder-cli-docs quality bump-dev bump-dev-dry-run bump-release bump-release-dry-run pin-actions
22

33

44
export check_dirs := kernels/src kernels/tests kernels-data/bindings/python
@@ -32,20 +32,20 @@ quality:
3232
# installed `kernels` package version (e.g. installed 0.13.0 -> 0.14.0.dev0).
3333
# Refreshes Cargo.lock and kernels/uv.lock so all sites stay consistent.
3434
bump-dev:
35-
python scripts/bump_to_dev.py
35+
python scripts/bump_version.py --dev
3636
cargo check --workspace
3737
cd kernels && uv lock
3838

3939
bump-dev-dry-run:
40-
python scripts/bump_to_dev.py --dry-run
40+
python scripts/bump_version.py --dev --dry-run
4141

4242
# Strip the `.dev0` / `-dev0` suffix from every version site in prep for a
4343
# release (e.g. codebase 0.14.0.dev0 -> 0.14.0). Refreshes Cargo.lock and
4444
# kernels/uv.lock so all sites stay consistent.
45-
pre-release:
46-
python scripts/pre_release.py
45+
bump-release:
46+
python scripts/bump_version.py
4747
cargo check --workspace
4848
cd kernels && uv lock
4949

50-
pre-release-dry-run:
51-
python scripts/pre_release.py --dry-run
50+
bump-release-dry-run:
51+
python scripts/bump_version.py --dry-run

kernel-abi-check/bindings/python/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "kernel-abi-check-python"
3-
version = "0.14.0-dev1"
3+
version = "0.15.0-dev0"
44
edition = "2024"
55
description = "Check the ABI of Hub Kernels"
66
homepage = "https://github.com/huggingface/kernel-builder"
@@ -17,3 +17,4 @@ pyo3 = { version = "0.26", features = ["abi3", "abi3-py38"] }
1717

1818
[dependencies.kernel-abi-check]
1919
path = "../../kernel-abi-check"
20+
version = "0.15.0-dev0"

kernel-abi-check/kernel-abi-check/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "kernel-abi-check"
3-
version = "0.14.0-dev1"
3+
version = "0.15.0-dev0"
44
edition = "2021"
55
description = "Check the ABI of Hub Kernels"
66
homepage = "https://github.com/huggingface/kernel-builder"

kernel-builder/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hf-kernel-builder"
3-
version = "0.14.0-dev1"
3+
version = "0.15.0-dev0"
44
edition = "2021"
55
description = "Build Hugging Face Hub kernels"
66
homepage = "https://github.com/huggingface/kernels"
@@ -10,7 +10,7 @@ repository = "https://github.com/huggingface/kernels"
1010

1111
[dependencies]
1212
base32 = "0.5"
13-
kernels-data = { path = "../kernels-data" }
13+
kernels-data = { path = "../kernels-data", version = "0.15.0-dev0" }
1414
clap = { version = "4", features = ["derive"] }
1515
clap-markdown = "0.1.5"
1616
clap_complete = "4"

kernels-data/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "kernels-data"
3-
version = "0.14.0-dev1"
3+
version = "0.15.0-dev0"
44
edition = "2024"
55
description = "Kernels data structures"
66
homepage = "https://github.com/huggingface/kernels"

kernels-data/bindings/python/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "kernels-data-python"
3-
version = "0.14.0-dev1"
3+
version = "0.15.0-dev0"
44
edition = "2024"
55
description = "Kernels data structures (Python bindings)"
66
homepage = "https://github.com/huggingface/kernels"
@@ -16,3 +16,4 @@ pyo3 = { version = "0.26", features = ["abi3", "abi3-py38"] }
1616

1717
[dependencies.kernels-data]
1818
path = "../.."
19+
version = "0.15.0-dev0"

kernels/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "kernels"
3-
version = "0.14.0.dev1"
3+
version = "0.15.0.dev0"
44
description = "Download compute kernels"
55
authors = [
66
{ name = "Daniel de Kok", email = "daniel@huggingface.co" },
@@ -11,7 +11,7 @@ readme = "README.md"
1111
requires-python = ">= 3.10"
1212
dependencies = [
1313
"huggingface-hub>=1.10.0",
14-
"kernels-data>=0.14.0.dev0",
14+
"kernels-data>=0.14.0.dev1",
1515
"packaging>=20.0",
1616
"pyyaml>=6",
1717
"tomli>=2.0; python_version<'3.11'",

kernels/uv.lock

Lines changed: 60 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/_version_common.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,77 @@ def get_codebase_version() -> Version:
5252
return Version(str(_version_table(doc, PRIMARY_PYPROJECT)["version"]))
5353

5454

55-
def replace_top_level_version(path: Path, new_version: str, *, dry_run: bool) -> str | None:
56-
doc = tomlkit.parse(path.read_text())
57-
table = _version_table(doc, path)
55+
def _set_top_level_version(doc, path: Path, new_version: str) -> str | None:
56+
"""Update the top-level version in an already-parsed tomlkit doc.
5857
58+
Returns the old version string, or *None* if it was already up-to-date.
59+
"""
60+
table = _version_table(doc, path)
5961
old_version = str(table["version"])
6062
if old_version == new_version:
6163
return None
62-
6364
table["version"] = new_version
64-
if not dry_run:
65+
return old_version
66+
67+
68+
def _set_path_dep_versions(doc, new_version: str) -> list[tuple[str, str]]:
69+
"""Update the ``version`` field of every dependency that also has a ``path`` key.
70+
71+
Path dependencies are local dependencies, but they need to have the correct version,
72+
otherwise `cargo publish` will croak.
73+
74+
Returns a list of ``(dep_name, old_version)`` for each dependency that was
75+
changed. Dependencies that only have a ``version`` (external crates.io deps)
76+
are left untouched.
77+
"""
78+
changed: list[tuple[str, str]] = []
79+
for dep_name, dep_value in doc.get("dependencies", {}).items():
80+
if not isinstance(dep_value, dict):
81+
continue
82+
if "path" not in dep_value or "version" not in dep_value:
83+
continue
84+
old = str(dep_value["version"])
85+
if old == new_version:
86+
continue
87+
dep_value["version"] = new_version
88+
changed.append((dep_name, old))
89+
return changed
90+
91+
92+
def replace_pyproject_version(
93+
path: Path, new_version: str, *, dry_run: bool
94+
) -> str | None:
95+
"""Rewrite the top-level version in a pyproject.toml file.
96+
97+
Returns the old version string, or *None* if the file was already
98+
up-to-date (in which case the file is not written).
99+
"""
100+
doc = tomlkit.parse(path.read_text())
101+
old_version = _set_top_level_version(doc, path, new_version)
102+
if old_version is not None and not dry_run:
65103
path.write_text(tomlkit.dumps(doc))
66104
return old_version
67105

68106

107+
def replace_cargo_version(
108+
path: Path, new_version: str, *, dry_run: bool
109+
) -> tuple[str | None, list[tuple[str, str]]]:
110+
"""Rewrite the package version and all versioned path-dependency versions
111+
in a Cargo.toml file in a single parse/write pass.
112+
113+
Returns ``(old_package_version | None, [(dep_name, old_dep_version), ...])``,
114+
where the first element is *None* when the package version was already
115+
up-to-date. The file is written at most once, and only when something
116+
actually changed.
117+
"""
118+
doc = tomlkit.parse(path.read_text())
119+
old_package = _set_top_level_version(doc, path, new_version)
120+
changed_deps = _set_path_dep_versions(doc, new_version)
121+
if (old_package is not None or changed_deps) and not dry_run:
122+
path.write_text(tomlkit.dumps(doc))
123+
return old_package, changed_deps
124+
125+
69126
def confirm(prompt: str) -> bool:
70127
try:
71128
answer = input(f"{prompt} [y/N]: ").strip().lower()

0 commit comments

Comments
 (0)