Skip to content

Commit

Permalink
[bazel] Use rules_python py_proto_library
Browse files Browse the repository at this point in the history
The `py_proto_library` has been deprecated from the `protobuf` repo. Instead, it recommends
using the `py_proto_library` from `rules_python`.

protocolbuffers/protobuf@1e8e356

When using bazel, if you want to use proto toolchains (see here:
https://github.com/aspect-build/toolchains_protoc) then the `protobuf`
implementation will not work as it depends directly on `@com_google_protobuf//:protoc`
instead of relying upon toolchain resolution. `rules_python`'s implementation
does not have this issue.
  • Loading branch information
schultetwin authored and PetteriAimonen committed Nov 15, 2024
1 parent b36a089 commit e94839c
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@nanopb_pypi//:requirements.bzl", "requirement")
load("@protobuf//:protobuf.bzl", "py_proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

# Note: if you are still using WORKSPACE, you will need to patch this file to use the following instead
# load("@python_3_11//:defs.bzl", "py_binary")
Expand Down Expand Up @@ -85,21 +85,9 @@ proto_library(
deps = ["@protobuf//:descriptor_proto"],
)

py_proto_library(
name = "descriptor_py_proto",
srcs = [
"generator/proto/google/protobuf/descriptor.proto",
],
include = "generator/proto",
)

py_proto_library(
name = "nanopb_py_proto",
srcs = [
"generator/proto/nanopb.proto",
],
include = "generator/proto",
deps = [":descriptor_py_proto"],
deps = [":nanopb_proto"],
)

cc_nanopb_proto_library(
Expand Down

0 comments on commit e94839c

Please sign in to comment.