Skip to content

Commit 2c50daf

Browse files
authored
chore: use bazel 9 by default (#3662)
Updates the project bazel version and bzlmod examples to use Bazel 9 Along the way, upgrade rules_go to 0.60.0; this is a dev-only dependency. This is needed because Bazel 9 removed CcInfo, and earlier rules_go versions refer to the builtin symbol. Also remove the test to check the bazel version. It doesn't do much useful.
1 parent be2f16e commit 2c50daf

6 files changed

Lines changed: 14 additions & 34 deletions

File tree

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.x
1+
9.x

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ bazel_dep(name = "another_module", version = "0", dev_dependency = True)
226226

227227
# Extra gazelle plugin deps so that WORKSPACE.bzlmod can continue including it for e2e tests.
228228
# We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides.
229-
bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
229+
bazel_dep(name = "rules_go", version = "0.60.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
230230

231231
internal_dev_deps = use_extension(
232232
"//python/private:internal_dev_deps.bzl",

examples/bzlmod/.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.x
1+
9.x

tests/BUILD.bazel

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2-
load("@rules_shell//shell:sh_test.bzl", "sh_test")
3-
load("//:version.bzl", "BAZEL_VERSION")
42

53
package(default_visibility = ["//visibility:public"])
64

@@ -27,29 +25,3 @@ build_test(
2725
"//python/entry_points:py_console_script_binary_bzl",
2826
],
2927
)
30-
31-
genrule(
32-
name = "assert_bazelversion",
33-
srcs = ["//:.bazelversion"],
34-
outs = ["assert_bazelversion_test.sh"],
35-
cmd = """\
36-
set -o errexit -o nounset -o pipefail
37-
current=$$(cat "$(execpath //:.bazelversion)")
38-
cat > "$@" <<EOF
39-
#!/usr/bin/env bash
40-
set -o errexit -o nounset -o pipefail
41-
if [[ \"$${{current}}\" != \"{expected}\" ]]; then
42-
>&2 echo "ERROR: current bazel version '$${{current}}' is not the expected '{expected}'"
43-
exit 1
44-
fi
45-
EOF
46-
""".format(
47-
expected = BAZEL_VERSION,
48-
),
49-
executable = True,
50-
)
51-
52-
sh_test(
53-
name = "assert_bazelversion_test",
54-
srcs = [":assert_bazelversion_test.sh"],
55-
)

tests/integration/local_toolchains/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ py_test(
2424
"//:py": "local",
2525
},
2626
# Make this test better respect pyenv
27-
env_inherit = ["PYENV_VERSION"],
27+
env_inherit = [
28+
"PYENV_VERSION",
29+
"PATH",
30+
],
2831
)
2932

3033
py_test(

tests/integration/local_toolchains/local_runtime_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@ def test_python_from_path_used(self):
1616
# that wouldn't be reflected when sub-shells are run later.
1717
shell_path = shutil.which("python3")
1818

19+
if shell_path is None:
20+
self.fail(
21+
"which(python3) returned None.\n" + f"PATH={os.environ.get('PATH')}"
22+
)
23+
1924
# We call the interpreter and print its executable because of
2025
# things like pyenv: they install a shim that re-execs python.
2126
# The shim is e.g. /home/user/.pyenv/shims/python3, which then
2227
# runs e.g. /usr/bin/python3
2328
with tempfile.TemporaryDirectory() as temp_dir:
2429
file_path = os.path.join(temp_dir, "info.py")
25-
with open(file_path, 'w') as f:
30+
with open(file_path, "w") as f:
2631
f.write(
27-
"""
32+
"""
2833
import sys
2934
print(sys.executable)
3035
print(sys._base_executable)

0 commit comments

Comments
 (0)