Skip to content

fix(toolchains): use target Python version for exec tools on Bazel 10 - #4335

Merged
rickeylev merged 1 commit into
bazel-contrib:mainfrom
rickeylev:add_bazel_10_support
Oct 24, 2026
Merged

rickeylev merged 1 commit into
bazel-contrib:mainfrom
rickeylev:add_bazel_10_support

Conversation

@rickeylev

Copy link
Copy Markdown
Collaborator

Bazel 10 enables
--incompatible_exclude_starlark_flags_from_exec_config by default
(bazelbuild/bazel#26909), which resets Starlark flags to their defaults
in the exec configuration unless they set scope = "universal". The
//python/config_settings:python_version flag had no scope, so exec
tools, such as the precompiler, ran with the default Python version
instead of the target's, e.g. compiling pyc files for the wrong Python
version.

To fix, give the python_version flag universal scope so its value
reaches the exec configuration again, as it did before Bazel 10. The
flag target sets the scope explicitly because Bazel ignores rule-level
scope defaults for flags set on the command line
(bazelbuild/bazel#31806).

Along the way, run the bazel-in-bazel integration tests with Bazel
10.0.0rc2, accept Bazel 10's reworded "no matching toolchains" error
in an integration test, and disable
--incompatible_no_implicit_file_export in the gazelle dev workspace
because the pinned rules_go version isn't compatible with it.

Fixes #3566
Fixes #3613
Work towards #3581

Bazel 10 resets Starlark flags in exec configurations unless they have
universal scope, so exec tools such as the precompiler used the default
Python version instead of the target's. Give the python_version flag
universal scope, and run the integration tests with Bazel 10.0.0rc2.

Fixes bazel-contrib#3566
Fixes bazel-contrib#3613
Work towards bazel-contrib#3581

@aignas aignas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! Thank you!

@rickeylev
rickeylev marked this pull request as ready for review October 24, 2026 00:21
@rickeylev
rickeylev requested a review from dougthor42 as a code owner October 24, 2026 00:21
@rickeylev
rickeylev added this pull request to the merge queue Oct 24, 2026
Merged via the queue into bazel-contrib:main with commit 159b6c2 Oct 24, 2026
13 checks passed
@rickeylev
rickeylev deleted the add_bazel_10_support branch October 24, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants