Skip to content

Commit

Permalink
chore: replace rules_proto with com_google_protobuf (#2487)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rickeylev authored Dec 9, 2024
1 parent b11f077 commit a7b7126
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 23 deletions.
4 changes: 4 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ load("//:internal_dev_deps.bzl", "rules_python_internal_deps")

rules_python_internal_deps()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
Expand Down
13 changes: 0 additions & 13 deletions examples/py_proto_library/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
Expand Down
2 changes: 1 addition & 1 deletion examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
Expand Down
4 changes: 0 additions & 4 deletions internal_dev_setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS")
Expand All @@ -46,9 +45,6 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

rules_java_dependencies()
Expand Down
4 changes: 3 additions & 1 deletion python/private/proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")
load("@com_google_protobuf//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")

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

Expand All @@ -31,6 +31,8 @@ bzl_library(
visibility = ["//python:__pkg__"],
deps = [
"//python:py_info_bzl",
"@com_google_protobuf//bazel/common:proto_common_bzl",
"@com_google_protobuf//bazel/common:proto_info_bzl",
"@rules_proto//proto:defs",
],
)
Expand Down
3 changes: 2 additions & 1 deletion python/private/proto/py_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

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

load("@rules_proto//proto:defs.bzl", "ProtoInfo", "proto_common")
load("@com_google_protobuf//bazel/common:proto_common.bzl", "proto_common")
load("@com_google_protobuf//bazel/common:proto_info.bzl", "ProtoInfo")
load("//python:py_info.bzl", "PyInfo")
load("//python/api:api.bzl", _py_common = "py_common")

Expand Down

0 comments on commit a7b7126

Please sign in to comment.