Skip to content

Commit 135af21

Browse files
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

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

bootcamp/WORKSPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ load(
1515
rules_magic_deps()
1616
rules_magic_leaflet_repo()
1717

18+
load("@rules_python//python:repositories.bzl", "py_repositories")
19+
20+
py_repositories()
21+
1822
load(
1923
"@rules_java//java:repositories.bzl",
2024
"rules_java_dependencies",

rules_magic/WORKSPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ load(
88

99
rules_magic_deps()
1010

11+
load("@rules_python//python:repositories.bzl", "py_repositories")
12+
13+
py_repositories()
14+
1115
load(
1216
"@rules_java//java:repositories.bzl",
1317
"rules_java_dependencies",

rules_magic/magic/deps.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ def rules_magic_deps():
2323
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
2424
],
2525
)
26+
27+
maybe(
28+
http_archive,
29+
name = "rules_python",
30+
sha256 = "c6fb25d0ba0246f6d5bd820dd0b2e66b339ccc510242fd4956b9a639b548d113",
31+
strip_prefix = "rules_python-0.37.2",
32+
url = "https://github.com/bazelbuild/rules_python/releases/download/0.37.2/rules_python-0.37.2.tar.gz",
33+
)

0 commit comments

Comments
 (0)