Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 153b533

Browse filesBrowse files
committed
fix: register autodetecting toolchain automatically
@bazel_tools depends on rules_python, but the version is currently specifies (0.22.0) doesn't register a toolchain by default. This means the Bazel builtin Python rules aren't usable because no toolchain is registered for them. Registering the toolchain directly in @bazel_tools inverts the problem: a toolchain is now always registered, but will usually always have precedence over any that rules_python registers (because @bazel_tools typically comes earlier in the module graph ordering). Upgrading bazel_tools past to 0.23.0 or higher (which register a Python toolchain automatically) is possible, but results in many failures in Bazel CI that are hard to figure out. To fix, we make rules_python register the autodetecting toolchain. Later rules_python versions register a different toolchain, but this at least gives Bazel something it can set as the minimum version that preserves existing behavior. Work towards bazelbuild/bazel#20458
1 parent 693a158 commit 153b533
Copy full SHA for 153b533

File tree

Expand file treeCollapse file tree

1 file changed

+9
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-0
lines changed

‎MODULE.bazel

Copy file name to clipboardExpand all lines: MODULE.bazel
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,12 @@ use_repo(
4949

5050
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
5151
use_repo(python, "pythons_hub")
52+
53+
# Necessary so that some toolchain is available so that the Python rules
54+
# work in some minimal capacity.
55+
# The @bazel_tools repo depends on rules_python, so expects rules_python
56+
# to register a toolchain. @bazel_tools can't register a Python toolchain
57+
# itself because @bazel_tools will typically come sooner in the module
58+
# graph BFS order (it is an implicit dep of every module), and would thus
59+
# override any toolchain rules_python registers.
60+
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.