From 602d11fc0ec386c78c185472527d993fc8e789e2 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sun, 7 Jun 2026 12:42:02 +0100 Subject: [PATCH] Fix `scripts/sync-python-version-constants.py` for non-pub consts and clean it up (#19700) ## Summary #19565 made most of the latest Python version constants non-public, but the script only matched `pub const` declarations. As a result, the daily Python release sync workflow silently stopped updating those constants. This PR fixes that. This PR also cleans up the script a bit (see individual commits for details). ## Test Plan Manual testing. --- scripts/sync-python-version-constants.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/sync-python-version-constants.py b/scripts/sync-python-version-constants.py index 8c85dd7045..7220865202 100644 --- a/scripts/sync-python-version-constants.py +++ b/scripts/sync-python-version-constants.py @@ -26,6 +26,7 @@ from packaging.version import Version SELF_DIR = Path(__file__).parent ROOT = SELF_DIR.parent +PYTHON_MINOR_VERSIONS = ("3.15", "3.14", "3.13", "3.12", "3.11", "3.10") def main() -> None: @@ -74,26 +75,23 @@ def main() -> None: lib_path = ROOT / "crates" / "uv-test" / "src" / "lib.rs" content = lib_path.read_text() - # Extract old values first old_versions: dict[str, str] = {} - for minor in ["3.15", "3.14", "3.13", "3.12", "3.11", "3.10"]: + for minor in PYTHON_MINOR_VERSIONS: const_name = f"LATEST_PYTHON_{minor.replace('.', '_')}" - match = re.search(rf'pub const {const_name}: &str = "([^"]+)";', content) + pattern = rf'const {const_name}: &str = "([^"]+)";' + match = re.search(pattern, content) if match: old_versions[minor] = match.group(1) - for minor in ["3.15", "3.14", "3.13", "3.12", "3.11", "3.10"]: if minor not in latest_versions: continue - const_name = f"LATEST_PYTHON_{minor.replace('.', '_')}" - old_pattern = rf'pub const {const_name}: &str = "[^"]+";' - new_value = f'pub const {const_name}: &str = "{latest_versions[minor]}";' - content = re.sub(old_pattern, new_value, content) + new_value = f'const {const_name}: &str = "{latest_versions[minor]}";' + content = re.sub(pattern, new_value, content) lib_path.write_text(content) updates = [] - for minor in ["3.15", "3.14", "3.13", "3.12", "3.11", "3.10"]: + for minor in PYTHON_MINOR_VERSIONS: if minor not in latest_versions: continue new_version = latest_versions[minor]