diff --git a/py/private/interpreter/repository.bzl b/py/private/interpreter/repository.bzl index f070cd51b..60d89f311 100644 --- a/py/private/interpreter/repository.bzl +++ b/py/private/interpreter/repository.bzl @@ -309,9 +309,15 @@ config_setting( exec_compatible_with = info["compatible_with"] + extra_exec_compatible content.append(""" +# The Python interpreter toolchain has no exec_compatible_with: the interpreter +# runs on the TARGET platform (inside the virtualenv), not on the exec host. +# Setting exec_compatible_with = platform_constraints would prevent this +# toolchain from being selected during cross-compilation (e.g. building an +# arm64 image on an amd64 host), because the exec platform (amd64) would not +# satisfy the arm64 exec constraint. The target_compatible_with constraint is +# sufficient to pick the right interpreter for the target. toolchain( name = "{name}", - exec_compatible_with = {exec_compatible_with}, target_compatible_with = {target_compatible_with}, target_settings = {target_settings}, toolchain = "@{repo}//:runtime_pair", @@ -323,7 +329,7 @@ toolchain( # binary on the build host regardless of the target platform being built for. toolchain( name = "{name}_exec_tools", - exec_compatible_with = {target_compatible_with}, + exec_compatible_with = {exec_compatible_with}, toolchain = "@{repo}//:exec_tools_toolchain", toolchain_type = "@aspect_rules_py//py/private/toolchain:exec_tools_toolchain_type", )