Skip to content

Commit 4d6c4f8

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.7.0", 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 remove `rules_proto` as a dependency and to rely directly upon `com_google_protobuf`. However, we'll keep `rules_proto` for now to illustrate a different upgrade path prior to depending on `com_google_protobuf` directly.
1 parent 4b9a942 commit 4d6c4f8

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
@@ -43,6 +43,10 @@ load(
4343

4444
rules_magic_deps()
4545

46+
load("@rules_python//python:repositories.bzl", "py_repositories")
47+
48+
py_repositories()
49+
4650
load(
4751
"@rules_java//java:repositories.bzl",
4852
"rules_java_dependencies",

rules_magic/WORKSPACE

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

3333
rules_magic_deps()
3434

35+
load("@rules_python//python:repositories.bzl", "py_repositories")
36+
37+
py_repositories()
38+
3539
load(
3640
"@rules_java//java:repositories.bzl",
3741
"rules_java_dependencies",

rules_magic/magic/deps.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,11 @@ def rules_magic_deps():
3737
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
3838
],
3939
)
40+
41+
maybe(
42+
http_archive,
43+
name = "rules_python",
44+
sha256 = "c6fb25d0ba0246f6d5bd820dd0b2e66b339ccc510242fd4956b9a639b548d113",
45+
strip_prefix = "rules_python-0.37.2",
46+
url = "https://github.com/bazelbuild/rules_python/releases/download/0.37.2/rules_python-0.37.2.tar.gz",
47+
)

0 commit comments

Comments
 (0)