From 9c8eb9bd6335818ff0c20b1d56e349c00118d9b7 Mon Sep 17 00:00:00 2001 From: "Wid L. Hacker" Date: Wed, 28 Oct 2026 11:48:35 -1000 Subject: [PATCH] version.py: accept semver-style prerelease tags (v0.10.0-rc.1) --- bindings/python/version.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bindings/python/version.py b/bindings/python/version.py index 964f5942..788334e1 100644 --- a/bindings/python/version.py +++ b/bindings/python/version.py @@ -9,6 +9,10 @@ v(.)+ [ {a|b|c|rc} (.)* ] + Semver-style prerelease tags (v0.10.0-rc.1, the form Cargo + requires for the crate version) are also accepted, normalized + to the PEP 386 form (0.10.0rc1). + If “git describe” returns an error (likely because we're in an unpacked copy of a release tarball, rather than a git working copy), or returns a tag that does not match the above format, version is read from RELEASE-VERSION file. @@ -74,6 +78,9 @@ def read_git_version(): if not ver: return None + # Normalize a semver-style prerelease segment (-rc.1) to the PEP 386 + # form (rc1) that _GIT_DESCRIPTION_RE parses. + ver = re.sub(r"(\d+(?:\.\d+)+)-(a|b|c|rc)\.?(\d+)", r"\1\2\3", ver) match = re.search(_GIT_DESCRIPTION_RE, ver) if not match: sys.stderr.write("version: git description (%s) is invalid, ignoring\n" % ver)