Skip to content

Commit a7b7126

Browse files
authored
chore: replace rules_proto with com_google_protobuf (#2487)
rules_proto is deprecated and recent versions simply forward onto com_google_protobuf. Older versions (e.g. 6.x used by us today), however, use the rules_proto or native (Bazel builtin) implementation. When those older versions are used with Bazel 9, which has removed various proto things, errors occur. To fix, switch to using com_google_protobuf directly. More recent versions of rules_proto just forward onto com_google_protobuf anyways, so this just removes the extra dependency and having to deal with WORKSPACE setup. Work towards #2469
1 parent b11f077 commit a7b7126

File tree

9 files changed

+13
-23
lines changed

9 files changed

+13
-23
lines changed

WORKSPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ load("//:internal_dev_deps.bzl", "rules_python_internal_deps")
2121

2222
rules_python_internal_deps()
2323

24+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
25+
26+
protobuf_deps()
27+
2428
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
2529

2630
rules_jvm_external_deps()

examples/bzlmod/py_proto_library/example.com/another_proto/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
22
load("@rules_python//python:proto.bzl", "py_proto_library")
33

44
py_proto_library(

examples/bzlmod/py_proto_library/example.com/proto/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
22
load("@rules_python//python:proto.bzl", "py_proto_library")
33

44
py_proto_library(

examples/py_proto_library/WORKSPACE

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@ python_register_toolchains(
2424
# Then we need to setup dependencies in order to use py_proto_library
2525
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2626

27-
http_archive(
28-
name = "rules_proto",
29-
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
30-
strip_prefix = "rules_proto-6.0.0-rc1",
31-
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
32-
)
33-
34-
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
35-
36-
rules_proto_dependencies()
37-
38-
rules_proto_toolchains()
39-
4027
http_archive(
4128
name = "com_google_protobuf",
4229
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",

examples/py_proto_library/example.com/another_proto/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
22
load("@rules_python//python:proto.bzl", "py_proto_library")
33

44
py_proto_library(

examples/py_proto_library/example.com/proto/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
22
load("@rules_python//python:proto.bzl", "py_proto_library")
33

44
py_proto_library(

internal_dev_setup.bzl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
2121
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
2222
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
2323
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
24-
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
2524
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
2625
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
2726
load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS")
@@ -46,9 +45,6 @@ def rules_python_internal_setup():
4645

4746
bazel_skylib_workspace()
4847

49-
rules_proto_dependencies()
50-
rules_proto_toolchains()
51-
5248
protobuf_deps()
5349

5450
rules_java_dependencies()

python/private/proto/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
16-
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")
16+
load("@com_google_protobuf//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
1717

1818
package(default_visibility = ["//visibility:private"])
1919

@@ -31,6 +31,8 @@ bzl_library(
3131
visibility = ["//python:__pkg__"],
3232
deps = [
3333
"//python:py_info_bzl",
34+
"@com_google_protobuf//bazel/common:proto_common_bzl",
35+
"@com_google_protobuf//bazel/common:proto_info_bzl",
3436
"@rules_proto//proto:defs",
3537
],
3638
)

python/private/proto/py_proto_library.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
"""The implementation of the `py_proto_library` rule and its aspect."""
1616

17-
load("@rules_proto//proto:defs.bzl", "ProtoInfo", "proto_common")
17+
load("@com_google_protobuf//bazel/common:proto_common.bzl", "proto_common")
18+
load("@com_google_protobuf//bazel/common:proto_info.bzl", "ProtoInfo")
1819
load("//python:py_info.bzl", "PyInfo")
1920
load("//python/api:api.bzl", _py_common = "py_common")
2021

0 commit comments

Comments
 (0)