Fix Python toolchain configuration in Bazel MODULE.bazel causing build failures #1603
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a Python toolchain configuration issue in the Bazel bzlmod setup that was causing build failures when emsdk is used as a dependency in other projects.
Problem
The build was failing with the error:
This occurred when building WebAssembly targets that depend on the
py_binary
rule in//emscripten_toolchain:wasm_binary
. The error manifested in projects like envoyproxy/examples when they used emsdk as a Bazel module dependency.Root Cause
The emsdk's
MODULE.bazel
was not properly configuring the Python toolchain for bzlmod. The Python extension neededis_default = True
and explicituse_repo()
statements to properly expose the Python repositories to the build system.Solution
is_default = True
in the Python toolchain configurationuse_repo()
to explicitly exposepython_3_13
andpython_versions
repositoriesThe configuration now follows the proper bzlmod pattern:
With the default toolchain properly configured, the
py_binary
rule can rely on the default Python toolchain without needing an explicitpython_version
attribute.