Repository navigation
Conversation
Bazel 7 native Python rules leave newer launcher placeholders unexpanded. This crashes venv-symlink parsing in the Python bootstrap and passes a literal interpreter-argument token as a script filename in the shell bootstrap. The main-file fallback also omits imports. Handle the unexpanded placeholders and restore native import ordering in both bootstraps when falling back to the main file. Normalize external entry-point paths in the shell fallback and preserve normal stage-2 behavior, interpreter arguments, and inherited PYTHONPATH. Add regression tests for both launchers and a release-note entry.
Use the Windows .exe.runfiles suffix when creating the launcher fixture. Build expected venv symlink paths with the platform path separator. This fixes the four blocking Windows jobs in PR bazel-contrib#4235 without changing launcher behavior.
This branch has not been deployed
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.
Fixes #4234. Reproductions and failure details are in
the issue.
Bazel 7's built-in Python rules leave newer launcher placeholders unexpanded
when using a rules_python runtime. The Python bootstrap crashes while parsing
%runtime_venv_symlinks%; the shell bootstrap passes%interpreter_args%toPython as a script filename. After bypassing the Python startup crash, its
direct-to-main fallback also omits declared import roots.
This completes the legacy compatibility path discussed in
PR #3495, without
changing normal stage-2 launches or the project's support policy.
Changes
unexpanded interpreter-argument token only in that fallback.
Bazel's workspace/repository settings; preserve inherited
PYTHONPATH.workspace/../prefix from shell entry-point paths so anexternal binary does not depend on the workspace directory existing.
entry for the generated changelog.
After the change, native hello targets start successfully and declared
dependencies are importable. Existing stage-2 import behavior and interpreter
arguments remain unchanged. No public APIs or build flags are added or changed.
Minimal reproduction
For the unpatched shell-launcher failure, use these four files:
Before: Python tries to open the literal
%interpreter_args%filename.After: the program prints
launcher reached main.The issue also contains the unpatched Python-launcher reproduction and an
explicitly crash-guarded example exposing the subsequent import failure.
These use Bzlmod and default runtimes, without custom toolchains or runfiles
manipulation.
Validation
All six targets passed locally with Bazel 9.1.1:
bazel test --config=fast-tests \ //tests/bootstrap_impls:native_bootstrap_test \ //tests/bootstrap_impls:native_bootstrap_script_test \ //tests/bootstrap_impls:interpreter_args_test \ //tests/bootstrap_impls:run_binary_bootstrap_script_zip_no_test \ //tests/bootstrap_impls:run_binary_bootstrap_script_find_runfiles_test \ //tests/bootstrap_impls:stdlib_shadowing_system_python_testThe new tests render the templates with native Bazel 7 substitutions; they do
not enable deprecated native rules in Bazel 9. They cover startup, import
ordering, workspace and external repository imports, inherited
PYTHONPATH,and unchanged stage-2 interpreter arguments.
The Bzlmod reproductions also pass against this fix with Bazel 7.7.1, including
the shell launcher, an external native target, and declared imports.
Buildifier, Ruff, and Bash syntax checks passed.
The release note is in
news/native-bootstrap-imports.fixed.md, following thecontribution guideline to use news fragments instead of editing the generated
CHANGELOG.mddirectly.