Repository navigation
fix(bazel): run gen_builds on the pinned Python toolchain - #4579
Closed
ScriptedAlchemy wants to merge 1 commit into
Closed
ScriptedAlchemy wants to merge 1 commit into
ScriptedAlchemy wants to merge 1 commit into
Conversation
`bazel run //scripts:bazel/gen_builds.py` executed an exported source file through its `#!/usr/bin/env python3` shebang, so the generator ran on whatever host python3 came first on PATH. The script needs 3.11+ (tomllib), and macOS ships 3.9, so the documented regeneration command failed for anyone without a newer Python installed. Wrap the generator in a `py_binary` like the other scripts so it runs on the rules_python toolchain, root it at BUILD_WORKSPACE_DIRECTORY when `bazel run` sets it, and point CI, docs, and the generated headers at `//scripts:gen_builds`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
ScriptedAlchemy
enabled auto-merge (squash)
October 27, 2026 02:50
Owner
Author
|
Superseded by #4543, which landed the same fix more completely: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
bazel run //scripts:bazel/gen_builds.pyruns an exported source file through its shebang, so it uses the hostpython3. The generator needs Python 3.11+ (tomllib). On macOS's system 3.9 the documented command fails withModuleNotFoundError: No module named 'tomllib'. A contributor who can't run it ends up with aCargo.tomlchange and staleBUILD.bazelfiles (e.g. #4574).Fix
py_binary(name = "gen_builds")so the generator runs on the rules_python toolchain (3.14 here).BUILD_WORKSPACE_DIRECTORYfor the repo root underbazel run, and fall back to the old__file__resolution otherwise.//scripts:gen_builds.Verification
bazel run //scripts:gen_builds -- --check→all 60 generated BUILD.bazel files are currenton a machine with only system Python 3.9.scripts/test-neutralize-release-pr-closing-keywords.pypasses.scripts/test-gen-builds-default-alias.pypasses under the toolchain Python. CI runs it with the runner'spython3, unchanged.🤖 Generated with Claude Code