wads.subpackages¶
Release a second package that lives in a subdirectory of the repo (i2mint/wads#220).
A repo can hold a pure-Python root package plus a maturin package in a subdirectory
(thorwhalen/equate: the root is equate, rust/ is equate-rust, which has its
own pyproject.toml). The root package keeps the ordinary publish job; each
subpackage listed here gets its own native release path:
[[tool.wads.ci.packages]]
dir = "rust" # holds a pyproject.toml; required
release = "on-change" # or "always": every release run
tag_prefix = "equate-rust-v" # tags are <tag_prefix><version>; default "<name>-v"
The subpackage’s own pyproject.toml configures it exactly as a root package is
configured ([tool.wads.ci.build.native], [tool.maturin]): subpackage_configs()
resolves it with wads.native_build.native_build_config(). With no
[[tool.wads.ci.packages]] nothing changes.
Release rule (plan_release()): on-change releases a package only when files under
its dir changed since its last tag (never tagged: it releases). The version is the next
patch after the last tag, or the version in the subpackage’s pyproject.toml when that is
higher, so a hand-raised minor or major is honoured and a stale one never goes backwards.
Tags are <tag_prefix><version>, so they do not collide with the root’s bare X.Y.Z.
Migrating a package that already releases from a hand-written workflow: create its first
tag (<tag_prefix><current version>) before enabling this, or the first run, finding no tag,
releases the version in pyproject.toml. The Rust checks (fmt, clippy, cargo test) run for each
releasing subpackage in the sub-rust-checks job, ahead of its wheels. Not covered yet: the
inline wads/data/github_ci_uv.yml has no subpackage jobs (the reusable workflow only).
Everything here is standard library only: the CI jobs load this file by path
(wads/scripts/_checkout_import.py), without installing wads.
Module Attributes
when a subpackage is released. |
Functions
|
The highest version among |
|
The release version: next patch after the last tag, unless the file is higher. |
|
|
|
The version to release for |
|
|
|
The repo's |
Classes
|
One entry of |
- wads.subpackages.RELEASE_MODES = ('on-change', 'always')¶
when a subpackage is released.
- Type:
releasevalues
- class wads.subpackages.SubPackage(dir, name, release, tag_prefix, native)[source]¶
Bases:
objectOne entry of
[[tool.wads.ci.packages]], resolved against its own pyproject.
- wads.subpackages.latest_tag_version(tags, tag_prefix)[source]¶
The highest version among
<tag_prefix>X.Y.Ztags, orNone.>>> latest_tag_version(["p-v0.1.2", "p-v0.1.10", "q-v9.0.0", "p-vx"], "p-v") (0, 1, 10)
- wads.subpackages.next_version(last_tag, committed)[source]¶
The release version: next patch after the last tag, unless the file is higher.
>>> next_version((0, 1, 2), (0, 1, 0)) # stale file: follow the tags (0, 1, 3) >>> next_version((0, 1, 2), (0, 2, 0)) # hand-raised minor: honoured (0, 2, 0) >>> next_version(None, (0, 1, 0)) # never tagged: release what the file says (0, 1, 0) >>> next_version(None, None) (0, 0, 1)
- Return type:
- wads.subpackages.parse_version(text)[source]¶
(major, minor, patch)of anX.Y.Zstring, elseNone.>>> parse_version("1.2.3"), parse_version("1.2"), parse_version("v1.2.3") ((1, 2, 3), None, None)
- wads.subpackages.plan_release(package, *, tags, committed_version, changed_since)[source]¶
The version to release for
packagenow, orNonewhen it does not release.changed_since(tag)says whether files under the package’s dir changed sincetag(called only foron-changepackages that have a tag).>>> from types import SimpleNamespace as NS >>> p = NS(dir="rust", release="on-change", tag_prefix="p-v") >>> plan_release(p, tags=["p-v0.1.0"], committed_version="0.1.0", changed_since=lambda t: False) >>> plan_release(p, tags=["p-v0.1.0"], committed_version="0.1.0", changed_since=lambda t: True) '0.1.1' >>> plan_release(p, tags=[], committed_version="0.1.0", changed_since=lambda t: False) '0.1.0' >>> plan_release(NS(dir="r", release="always", tag_prefix="p-v"), tags=["p-v1.0.0"], ... committed_version="0.1.0", changed_since=lambda t: False) '1.0.1'
- wads.subpackages.stamp_version(pyproject_text, version)[source]¶
pyproject_textwith[project].versionset toversion.>>> stamp_version('[project]\nname = "p"\nversion = "0.1.0"\n[tool.x]\nversion = "9"\n', "0.2.0") '[project]\nname = "p"\nversion = "0.2.0"\n[tool.x]\nversion = "9"\n'
- Return type:
- wads.subpackages.subpackage_configs(pyproject, *, read_pyproject)[source]¶
The repo’s
SubPackagelist (empty when it declares none).read_pyproject(dir)returns the parsed<dir>/pyproject.toml. RaisesValueErroron an entry that does not parse, asnative_build_config()does.>>> data = {"tool": {"wads": {"ci": {"packages": [{"dir": "rust"}]}}}} >>> sub = {"project": {"name": "pkg-rust", "version": "0.1.0"}, "build-system": {"build-backend": "maturin"}} >>> [(p.dir, p.name, p.release, p.tag_prefix) ... for p in subpackage_configs(data, read_pyproject=lambda d: sub)] [('rust', 'pkg-rust', 'on-change', 'pkg-rust-v')] >>> subpackage_configs({}, read_pyproject=lambda d: sub) []
- Return type: