From d4d51678ded6dc1b8de709bd67f468fcd7f1db28 Mon Sep 17 00:00:00 2001 From: Andrew Fish Date: Tue, 13 Oct 2026 13:29:02 -0700 Subject: [PATCH] fix(toolchains): mark the python extension os- and arch-dependent The `python` extension picks the runtimes behind each `*_host` repo by matching them against `module_ctx.os`, but does not declare that its result depends on the host. Being reproducible, it stays out of the workspace `MODULE.bazel.lock`, yet Bazel 8.8.1 and 9.1.1 still record its result in the output base's own lockfile under a single `general` key. When one output base serves two architectures, such as a cache volume shared by amd64 and arm64 containers, the second host reuses the first host's result and fetching the host repo fails: Could not find a compatible 'host' python for 'linux', 'aarch64' from the loaded platforms: ["x86_64-unknown-linux-gnu", ...] Declaring the extension `os_dependent` and `arch_dependent` keys the recorded result by host OS and CPU, so each host evaluates it for itself. Bazel 7.7.1 does not record the extension and is unaffected. --- news/python-ext-os-arch-dependent.fixed.md | 3 +++ python/private/python.bzl | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 news/python-ext-os-arch-dependent.fixed.md diff --git a/news/python-ext-os-arch-dependent.fixed.md b/news/python-ext-os-arch-dependent.fixed.md new file mode 100644 index 0000000000..ea17098e84 --- /dev/null +++ b/news/python-ext-os-arch-dependent.fixed.md @@ -0,0 +1,3 @@ +(toolchains) The `python` extension is re-evaluated when the host OS or CPU +changes, so an output base shared between hosts no longer fails to fetch the +`*_host` interpreter repo. diff --git a/python/private/python.bzl b/python/private/python.bzl index 05334c3da1..19db885e57 100644 --- a/python/private/python.bzl +++ b/python/private/python.bzl @@ -1624,6 +1624,8 @@ python = module_extension( "toolchain": _toolchain, }, environ = ["RULES_PYTHON_BZLMOD_DEBUG"], + os_dependent = True, + arch_dependent = True, ) _DEBUG_BUILD_CONTENT = """