Skip to content

refactor(toolchains): define the Python toolchain type in rules_python (#4404) - #4521

Merged
aignas merged 1 commit into
bazel-contrib:release/1.9from
fmeum:backport-4404-release-1.9
Nov 17, 2026
Merged

aignas merged 1 commit into
bazel-contrib:release/1.9from
fmeum:backport-4404-release-1.9

Conversation

@fmeum

@fmeum fmeum commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Backports #4404 to release/1.9, as discussed on that PR, so that Bazel's @bazel_tools can depend on a 1.x release of rules_python.

//python:toolchain_type is an alias of the type in @bazel_tools. To move the type out of @bazel_tools, Bazel will forward @bazel_tools//tools/python:toolchain_type to this target (bazelbuild/bazel#32412), which requires it to be the actual type on those Bazel versions.

//python:toolchain_type is now a toolchain_type if a new value in the @rules_python_internal config is set and remains an alias otherwise, so both labels always refer to the same type. The config extension sets the value from a bazel_features flag, which is False for now, so nothing changes yet. WORKSPACE builds leave it unset, as Bazel versions that forward the type no longer support WORKSPACE.

Differences from the commit on main:

  • The new bzl_library is named python_toolchain_type_bzl to follow this branch's naming convention.
  • The tests/integration/bzlmod_lockfile lockfile update is dropped, since that test does not exist on this branch.

Work towards bazelbuild/bazel#32428

bazel-contrib#4404)

`//python:toolchain_type` is an alias of the type in `@bazel_tools`. To
move the type out of `@bazel_tools`, Bazel will forward
`@bazel_tools//tools/python:toolchain_type` to this target
(bazelbuild/bazel#32412), which requires it to be the actual type on
those Bazel versions.

`//python:toolchain_type` is now a `toolchain_type` if a new value in
the `@rules_python_internal` config is set and remains an alias
otherwise, so both labels always refer to the same type. The `config`
extension sets the value from a `bazel_features` flag, which is `False`
for now, so nothing changes yet. WORKSPACE builds leave it unset, as
Bazel versions that forward the type no longer support WORKSPACE. This
also avoids requiring `bazel_features` in WORKSPACE builds.

Work towards bazelbuild/bazel#32428

---------

Co-authored-by: Richard Levasseur <richardlev@gmail.com>
(cherry picked from commit 1bf79e9)
@fmeum

fmeum commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

This backport was prepared with Claude Code at the request of the PR author. The cherry-pick conflicts were limited to context lines missing on release/1.9. No agent is monitoring this PR to reply automatically; the PR author will handle review comments directly.

This comment was generated by an AI agent (Claude Code) and posted automatically, without prior review by the user.

@fmeum

fmeum commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@rickeylev @aignas When this has been merged, it would be really helpful if you could cut new releases so that Bazel 10 has enough time to adopt and test them. The switch won't go live until a new bazel_features release, so we have a way of gating it behind a flag of sorts.

@fmeum

fmeum commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

The soft-failing Default: Ubuntu, upcoming Bazel and Default: Ubuntu, rolling Bazel jobs fail these tests, which also fail on release/1.9 without this change (reproduced locally with rolling Bazel):

  • //tests/toolchains/transitions:test_minor_versions
  • //tests/toolchains/transitions:test_full_version
  • //tests/exec_toolchain_matching:test_exec_matches_target_python_version

This comment was generated by an AI agent (Claude Code) and posted at the PR author's request.

@aignas
aignas merged commit 05c2b67 into bazel-contrib:release/1.9 Nov 17, 2026
3 checks passed
@fmeum
fmeum deleted the backport-4404-release-1.9 branch November 17, 2026 14:45
@rickeylev

Copy link
Copy Markdown
Collaborator

created a tracking issue so we don't lose track of what is where #4525

@rickeylev rickeylev mentioned this pull request Nov 18, 2026
3 tasks
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.

3 participants