Skip to content

feat: add //command_line_option:extra_toolchains pseudo-flag#3810

Open
rickeylev wants to merge 4 commits into
bazel-contrib:mainfrom
rickeylev:add-extra-toolchains-flag
Open

feat: add //command_line_option:extra_toolchains pseudo-flag#3810
rickeylev wants to merge 4 commits into
bazel-contrib:mainfrom
rickeylev:add-extra-toolchains-flag

Conversation

@rickeylev
Copy link
Copy Markdown
Collaborator

Add support for transitioning on the //command_line_option:extra_toolchains built-in flag using py_binary.config_settings.

Note that, unlike the normal Bazel built-in flag, it must be specified as a simple comma-separated string when set using config_settings, which is then parsed as a CSV string.

This is to make it easier to, on a per-target basis, such as with a zipapp or wheels,
change the Python toolchains used.

@rickeylev rickeylev requested a review from aignas as a code owner June 6, 2026 03:47
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the Bazel-builtin --extra_toolchains flag via a pseudo-flag //command_line_option:extra_toolchains. It includes parsing logic to convert a comma-separated string into a list of toolchains, updates transition labels, and adds documentation and tests. The feedback suggests using the newly defined labels.EXTRA_TOOLCHAINS constant in python/private/transition_labels.bzl instead of a hardcoded string literal to maintain consistency.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread python/private/transition_labels.bzl
Add support for transitioning on the //command_line_option:extra_toolchains
built-in flag using py_binary.config_settings.

Note that, unlike the normal Bazel built-in flag, it must be specified as
a simple comma-separated string when set using config_settings, which is
then parsed as a CSV string.

This is implemented by:
- Adding an alias extra_toolchains in command_line_option/BUILD.bazel.
- Adding //command_line_option:extra_toolchains to TRANSITION_LABELS so
  that it is inherited by all transition-using rules (py_wheel, py_zipapp,
  etc).
- Updating apply_config_settings_attr in python/private/attributes.bzl to
  parse the extra_toolchains CSV string into a list of strings when set
  via config_settings.
- Adding a test case and updating documentation.
@rickeylev rickeylev force-pushed the add-extra-toolchains-flag branch from f2c6037 to 7121412 Compare June 6, 2026 17:07
@rickeylev rickeylev enabled auto-merge June 6, 2026 17:51
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