Repository navigation
fix: preserve bootstrap_impl in exec config - #4477
Open
StephanDollberg wants to merge 2 commits into
Open
StephanDollberg wants to merge 2 commits into
StephanDollberg wants to merge 2 commits into
Conversation
With Bazel 10, `--bootstrap_impl=script` no longer applies to Python executables built as tools, e.g. a `py_binary` run by a `genrule`. They fall back to `system_python` and fail to start on hosts without a `python3`. Give the flag universal scope, as 159b6c2 did for `python_version` and 05916c1 for `venvs_use_declare_symlink`.
Author
|
PR was created with AI help, I'll be responding to comments myself. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The existing genrule tests do not cover command-line bootstrap flag propagation into the exec configuration, leaving a regression test with a plain py_binary tool under Bazel 10 needed.
1 open issue
What changed in this PR
Preserves --bootstrap_impl across Bazel 10 exec transitions so Python build tools honor the selected bootstrap instead of reverting to system_python.
Changes:
- Adds a
scopeattribute to rules_python’s string build-setting rule. - Gives
bootstrap_impluniversal scope so its value propagates to build tools. - Documents the behavior and adds a release note.
| File | Description |
|---|---|
python/private/flags.bzl |
Exposes the Bazel-recognized scope attribute. |
python/config_settings/BUILD.bazel |
Sets universal scope for bootstrap_impl. |
news/bootstrap-impl-exec-config.fixed.md |
Announces the Bazel 10 build-tool bootstrap fix. |
docs/api/rules_python/python/config_settings/index.md |
Documents flag propagation to exec configurations. |
Review effort: Balanced
| # configuration. Bazel 10 resets Starlark flags in exec configurations | ||
| # unless they have universal scope | ||
| # (https://github.com/bazelbuild/bazel/issues/26909). | ||
| scope = "universal", |
Author
There was a problem hiding this comment.
Will do if maintainers agree.
Collaborator
There was a problem hiding this comment.
Yes please, a test for this would be good.
Builds a py_binary genrule tool with --bootstrap_impl=script set on the command line and checks that it gets the script bootstrap.
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.

With Bazel 10,
--bootstrap_impl=scriptno longer applies to Pythonexecutables built as tools, e.g. a
py_binaryrun by agenrule. Theyfall back to
system_pythonand fail to start on hosts without apython3.Give the flag universal scope, as 159b6c2 did for
python_versionand05916c1 for
venvs_use_declare_symlink.