Skip to content

Commit 075196c

Browse files
authored
Remove auto-detection of Python toolchain from MODULE.bazel (#4582)
since it affects downstream users The correct solution appears to be https://rules-python.readthedocs.io/en/stable/toolchains.html#library-modules-with-dev-only-python-usage This change also includes a workaround for the new mechanism creating paths that are too long for Windows to handle. Backport of 3e3b44c
1 parent e397860 commit 075196c

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

MODULE.bazel

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
module(
3434
name = "googletest",
35-
version = "1.15.0",
35+
version = "1.15.1",
3636
compatibility_level = 1,
3737
)
3838

@@ -51,11 +51,19 @@ bazel_dep(name = "re2",
5151
version = "2024-07-02")
5252

5353
bazel_dep(name = "rules_python",
54-
version = "0.29.0")
54+
version = "0.34.0",
55+
dev_dependency = True)
5556

57+
# https://rules-python.readthedocs.io/en/stable/toolchains.html#library-modules-with-dev-only-python-usage
58+
python = use_extension(
59+
"@rules_python//python/extensions:python.bzl",
60+
"python",
61+
dev_dependency = True
62+
)
63+
64+
python.toolchain(python_version = "3.12",
65+
is_default = True,
66+
ignore_root_user_error = True)
5667

5768
fake_fuchsia_sdk = use_repo_rule("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk")
5869
fake_fuchsia_sdk(name = "fuchsia_sdk")
59-
60-
# https://github.com/bazelbuild/rules_python/blob/main/BZLMOD_SUPPORT.md#default-toolchain-is-not-the-local-system-python
61-
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")

ci/windows-presubmit.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ RMDIR /S /Q cmake_msvc2022
4646
:: ----------------------------------------------------------------------------
4747
:: Bazel
4848

49+
:: The default home directory on Kokoro is a long path which causes errors
50+
:: because of Windows limitations on path length.
51+
:: --output_user_root=C:\tmp causes Bazel to use a shorter path.
4952
SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
50-
%BAZEL_EXE% test ... ^
53+
%BAZEL_EXE% ^
54+
--output_user_root=C:\tmp ^
55+
test ... ^
5156
--compilation_mode=dbg ^
5257
--copt=/std:c++14 ^
5358
--copt=/WX ^

0 commit comments

Comments
 (0)