Skip to content

Fix BCR presubmit, update rules_python to 1.5.2 #1760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,5 @@ use_repo(
"org_golang_x_tools",
)

bazel_dep(name = "rules_python", version = "1.5.1", dev_dependency = True)
bazel_dep(name = "rules_python", version = "1.5.2", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.5.1", dev_dependency = True)
1 change: 0 additions & 1 deletion examples/crossbuild/protobuf.patch

This file was deleted.

91 changes: 91 additions & 0 deletions examples/crossbuild/protobuf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
diff --git a/protobuf.bzl b/protobuf.bzl
index 283c85850..ad91faba6 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -1,7 +1,9 @@
load("@bazel_skylib//lib:versions.bzl", "versions")
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@rules_python//python:defs.bzl", "py_library")
+load("//bazel/common:proto_common.bzl", "proto_common")
load("//bazel/common:proto_info.bzl", "ProtoInfo")
+load("//bazel/private:toolchain_helpers.bzl", "toolchains")

def _GetPath(ctx, path):
if ctx.label.workspace_root:
@@ -71,6 +73,26 @@ def _CsharpOuts(srcs):
for src in srcs
]

+_PROTOC_ATTRS = toolchains.if_legacy_toolchain({
+ "_proto_compiler": attr.label(
+ cfg = "exec",
+ executable = True,
+ allow_files = True,
+ default = configuration_field("proto", "proto_compiler"),
+ ),
+})
+_PROTOC_FRAGMENTS = ["proto"]
+_PROTOC_TOOLCHAINS = toolchains.use_toolchain(toolchains.PROTO_TOOLCHAIN)
+
+def _protoc_files_to_run(ctx):
+ if proto_common.INCOMPATIBLE_ENABLE_PROTO_TOOLCHAIN_RESOLUTION:
+ toolchain = ctx.toolchains[toolchains.PROTO_TOOLCHAIN]
+ if not toolchain:
+ fail("Protocol compiler toolchain could not be resolved.")
+ return toolchain.proto.proto_compiler
+ else:
+ return ctx.attr._proto_compiler[DefaultInfo].files_to_run
+
ProtoGenInfo = provider(
fields = ["srcs", "import_flags", "deps"],
)
@@ -310,7 +332,7 @@ def _internal_gen_well_known_protos_java_impl(ctx):
args.add_all([src.path[offset:] for src in dep.direct_sources])

ctx.actions.run(
- executable = ctx.executable._protoc,
+ executable = _protoc_files_to_run(ctx),
inputs = descriptors,
outputs = [srcjar],
arguments = [args],
@@ -334,12 +356,9 @@ internal_gen_well_known_protos_java = rule(
"javalite": attr.bool(
default = False,
),
- "_protoc": attr.label(
- executable = True,
- cfg = "exec",
- default = "//:protoc",
- ),
- },
+ } | _PROTOC_ATTRS,
+ fragments = _PROTOC_FRAGMENTS,
+ toolchains = _PROTOC_TOOLCHAINS,
)

def _internal_gen_kt_protos(ctx):
@@ -373,7 +392,7 @@ def _internal_gen_kt_protos(ctx):
args.add_all([src.path[offset:] for src in dep.direct_sources])

ctx.actions.run(
- executable = ctx.executable._protoc,
+ executable = _protoc_files_to_run(ctx),
inputs = descriptors,
outputs = [srcjar],
arguments = [args],
@@ -397,12 +416,9 @@ internal_gen_kt_protos = rule(
"lite": attr.bool(
default = False,
),
- "_protoc": attr.label(
- executable = True,
- cfg = "exec",
- default = "//:protoc",
- ),
- },
+ } | _PROTOC_ATTRS,
+ fragments = _PROTOC_FRAGMENTS,
+ toolchains = _PROTOC_TOOLCHAINS,
)

def internal_objc_proto_library(
11 changes: 3 additions & 8 deletions scala/latest_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,12 @@ def rules_scala_dependencies():
),
)

# Can't upgrade for now because https://github.com/bazel-contrib/rules_python/pull/2760
# broke Bazel 7 WORKSPACE builds. It's really only a dev dep anyway.
# If it's fixed per https://github.com/bazel-contrib/rules_python/issues/3119
# (i.e., once https://github.com/bazel-contrib/rules_python/pull/3134 lands),
# then we can upgrade.
maybe(
http_archive,
name = "rules_python",
sha256 = "9f9f3b300a9264e4c77999312ce663be5dee9a56e361a1f6fe7ec60e1beef9a3",
strip_prefix = "rules_python-1.4.1",
url = "https://github.com/bazelbuild/rules_python/releases/download/1.4.1/rules_python-1.4.1.tar.gz",
sha256 = "0e68f851a6fcf317eeab5f6dc79803cb183d30c0c65fb52e2c4b731d13b73349",
strip_prefix = "rules_python-1.5.2",
url = "https://github.com/bazelbuild/rules_python/releases/download/1.5.2/rules_python-1.5.2.tar.gz",
)

maybe(
Expand Down