Skip to content

refactor: don't depend on @bazel_tools//tools/python files - #4236

Open
fmeum wants to merge 4 commits into
bazel-contrib:mainfrom
fmeum:no-bazel-tools-python
Open

fmeum wants to merge 4 commits into
bazel-contrib:mainfrom
fmeum:no-bazel-tools-python

Conversation

@fmeum

@fmeum fmeum commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Bazel is trimming unused content from @bazel_tools (bazelbuild/bazel#31549, bazelbuild/bazel#31692). Two references from rules_python currently block the removal of @bazel_tools//tools/python files that are otherwise unused:

  • The root //:bzl filegroup re-exports @bazel_tools//tools/python:{python_version,srcs_version,toolchain,utils}.bzl. rules_python doesn't load any of them; srcs_version.bzl, toolchain.bzl and utils.bzl have no remaining users (py_runtime_pair in toolchain.bzl just fails since Bazel 8). Before: //:bzl contains these four files. After: it only contains rules_python's own .bzl files.
  • The _bootstrap_template attribute of the executable rules, which is only used when no Python runtime is available, defaulted to @bazel_tools//tools/python:python_bootstrap_template.txt. rules_python already ships its own, newer copy of that template as //python/private:python_bootstrap_template.txt, which py_runtime uses by default. Before: the fallback uses Bazel's frozen template. After: it uses rules_python's.

The remaining references to @bazel_tools//tools/python (the toolchain type, the python_version flag and the interpreter path constraints) are unchanged.

fmeum added 3 commits October 9, 2026 22:04
The `//:bzl` filegroup re-exported `.bzl` files from
`@bazel_tools//tools/python` that rules_python doesn't load, and the
`_bootstrap_template` fallback of the executable rules pointed to
Bazel's frozen copy of the bootstrap template even though rules_python
ships its own. Bazel would like to remove the unused files from
`@bazel_tools`, which these references currently block.
@fmeum
fmeum marked this pull request as ready for review October 10, 2026 13:36
@rickeylev

Copy link
Copy Markdown
Collaborator

Hrm. It seems that old bootstrap is somehow load bearing for windows >.< . I think the proper fix is to get rid of that implicit attribute entirely. Lets make a quick try to just remove that entire _bootstrap_template implicit attribute. If it gets messy, lets just copy the ye olde bazel bootstrap template into rules_python, make it only used by windows, name it such, and figure out how to excise it later.

Can you split the filegroup(bzl) into a separate PR? That should be an easy merge.

Remove the unsupported 1-stage bootstrap codepath and _bootstrap_template attribute from py_executable.bzl. Configure _magic_sentinel_runtime with supports_build_time_venv = False and resolve --python_path in _get_interpreter_path so Windows runtime_env_toolchain uses the standard 2-stage bootstrap and runtime venv creation.

This branch has not been deployed

No deployments
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.

2 participants