Skip to content

Conversation

mmorel-35
Copy link

@mmorel-35 mmorel-35 commented Sep 20, 2025

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:

Unable to find package for @@[unknown repo 'python3_12' requested from @@envoy~~core~emsdk (did you mean 'python_3_12'?)]//:defs.bzl

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 needed is_default = True and explicit use_repo() statements to properly expose the Python repositories to the build system.

Solution

  1. Added proper Python toolchain configuration: Set is_default = True in the Python toolchain configuration
  2. Added explicit repository exposure: Used use_repo() to explicitly expose python_3_13 and python_versions repositories

The configuration now follows the proper bzlmod pattern:

python.toolchain(
    is_default = True,
    python_version = "3.13",
)
use_repo(
    python,
    "python_3_13",
    python = "python_versions",
)

With the default toolchain properly configured, the py_binary rule can rely on the default Python toolchain without needing an explicit python_version attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant