Commit 135af21
committed
Add rules_python 0.37.2 for Bazel 7
Adding a newer `rules_python` to `rules_magic_deps` _before_
`rules_proto` fixes the missing `rules_python` file error from the
previous commit.
rules_python 0.37.2 is the last version that doesn't pull in its own
`protobuf`. `rules_python` 0.38.0 pulls in protobuf v27 unconditionally.
0.37.2 allows us to keep using rules_proto-5.3.0-21.7 for now.
Also, `rules_python` 0.40.0 and later require newer `rules_cc` versions
that may not play nice with `protobuf` v21.7. After we upgrade
`protobuf` to a more recent version, we can upgrade to more recent
`rules_python` version. For details:
- bazel-contrib/rules_scala#1660 (comment)
The build now produces the following failure:
```txt
ERROR: external/remote_java_tools_darwin_arm64/BUILD:
no such target
'@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
target 'turbine_direct_graal' not declared in package ''
defined by external/remote_java_tools_darwin_arm64/BUILD
ERROR: external/rules_java_builtin/toolchains/BUILD:163:14:
no such target
'@@remote_java_tools_darwin_arm64//:turbine_direct_graal':
target 'turbine_direct_graal' not declared in package ''
defined by external/remote_java_tools_darwin_arm64/BUILD
and referenced by
'@@rules_java_builtin//toolchains:turbine_direct_graal_darwin_arm64'
ERROR: Analysis of target '//:default-values' failed; build aborted:
Analysis failed
```
Another `rules_java_builtin` and user-declared `rules_java` conflict due
to the legacy `WORKSPACE` model:
- `rules_java` 7.3.0 introduced the `turbine_direct_graal` target into its
`//toolchains` package via:
bazelbuild/rules_java#151: Use Turbine native image as
`header_compiler_direct`
bazelbuild/rules_java@d5b3ecf
- As noted in "Bump to Bazel 7.6.2", the legacy `WORKSPACE` prefix
creates `@rules_java_builtin`, which is actually `rules_java` 7.6.5.
This version depends on `remote_java_tools` v13.6.1, whose repos
contain `//:turbine_direct_graal`. Its `README.md` shows that it
comes from bazelbuild/bazel@40ec2cd.
https://github.com/bazelbuild/rules_java/blob/7.6.5/java/repositories.bzl#L25
https://github.com/bazelbuild/java_tools/releases/download/java_13.6.1/java_tools_darwin_arm64-v13.6.1.zip
https://github.com/bazelbuild/bazel/blob/40ec2cd1a15d73473945475552ad1d0cb6d77927/tools/jdk/BUILD.java_tools_prebuilt#L26-L32
- The legacy `bootcamp/WORKSPACE` file invokes `rules_java_dependencies`
from `rules_java` 6.5.2, instantiating `remote_java_tools` v12.6,
whose repos do _not_ contain `//:turbine_direct_graal`. It comes from
bazelbuild/bazel@bd91cb1.
https://github.com/bazelbuild/rules_java/blob/6.5.2/java/repositories.bzl#L31
https://github.com/bazelbuild/java_tools/releases/download/java_v12.6/java_tools_darwin_arm64-v12.6.zip
https://github.com/bazelbuild/bazel/blob/bd91cb131785a6693d45c7840a229d345e48d40b/tools/jdk/BUILD.java_tools_prebuilt
- The legacy `WORKSPACE` suffix invokes `rules_java_dependencies` from
`rules_java` 7.6.5. Since it wraps the `http_archive` repo rules
instantiating `remote_java_tools` repos with `maybe`, nothing happens,
because the repos already exist.
- The legacy `WORKSPACE` suffix then invokes `rules_java_toolchains`
from `rules_java` 7.6.5, which registers `//toolchains:all`.
- That version of the `//toolchains` package aliases
`"turbine_direct_graal_%s" % OS` to
`"@remote_java_tools_%s//:turbine_direct_graal" % OS`.
https://github.com/bazelbuild/rules_java/blob/7.6.5/toolchains/BUILD#L163-L166
- Since the `"@remote_java_tools_%s" % OS` repo doesn't contain a
`turbine_direct_graal` target, analysis of `//toolchains:all` breaks.
---
Another solution would've been to apply the following patch to remove
`rules_proto` as a dependency and rely only on `com_google_protobuf`.
However, we'll keep `rules_proto` to illustrate a different upgrade path
prior to depending on `com_google_protobuf` directly.
```diff
diff --git i/bootcamp/WORKSPACE w/bootcamp/WORKSPACE
index 3e7a614..0b13a55 100644
--- i/bootcamp/WORKSPACE
+++ w/bootcamp/WORKSPACE
@@ -24,15 +24,6 @@ load(
rules_java_dependencies()
rules_java_toolchains()
-load(
- "@rules_proto//proto:repositories.bzl",
- "rules_proto_dependencies",
- "rules_proto_toolchains",
-)
-
-rules_proto_dependencies()
-rules_proto_toolchains()
-
load("@com_frobozz_rules_magic//magic:config.bzl", "magic_config")
magic_config(
diff --git i/rules_magic/magic/deps.bzl w/rules_magic/magic/deps.bzl
index 984e8ae..23b64af 100644
--- i/rules_magic/magic/deps.bzl
+++ w/rules_magic/magic/deps.bzl
@@ -15,11 +15,9 @@ def rules_magic_deps():
maybe(
http_archive,
- name = "rules_proto",
- sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
- strip_prefix = "rules_proto-5.3.0-21.7",
+ name = "com_google_protobuf",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
- "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
+ "https://github.com/protocolbuffers/protobuf/releases/download/v21.7/protobuf-all-21.7.zip",
],
+ sha256 = "5493a21f5ed3fc502e66fec6b9449c06a551ced63002fa48903c40dfa8de7a4a",
)
```1 parent 91297a8 commit 135af21
3 files changed
+16
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
0 commit comments