Skip to content

Commit

Permalink
fix: add protobuf via requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
aignas committed Feb 9, 2023
1 parent 85ac8bb commit bd26d71
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 1 deletion.
11 changes: 11 additions & 0 deletions examples/py_proto_library/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
load("@pip//:requirements.bzl", "requirement")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
Expand All @@ -18,5 +20,14 @@ py_test(
main = "test.py",
deps = [
":pricetag_proto_py_pb2",
# Add 'protobuf' dependency in the libraries consuming the py_proto_libraries.
requirement("protobuf"),
],
)

compile_pip_requirements(
name = "requirements",
extra_args = ["--resolver=backtracking"],
requirements_in = "requirements.in",
requirements_txt = "requirements.txt",
)
7 changes: 7 additions & 0 deletions examples/py_proto_library/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ register_toolchains(

# We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

pip = use_extension("@rules_python//python:extensions.bzl", "pip")
pip.parse(
name = "pip",
requirements_lock = "//:requirements.txt",
)
use_repo(pip, "pip")
14 changes: 14 additions & 0 deletions examples/py_proto_library/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,17 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_
rules_proto_dependencies()

rules_proto_toolchains()

load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

# For example on how to use pip_parse see ../pip_parse/WORKSPACE
pip_parse(
name = "pip",
python_interpreter_target = interpreter,
requirements_lock = "//:requirements.txt",
)

load("@pip//:requirements.bzl", "install_deps")

install_deps()
1 change: 1 addition & 0 deletions examples/py_proto_library/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
protobuf == 3.20.3
30 changes: 30 additions & 0 deletions examples/py_proto_library/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
protobuf==3.20.3 \
--hash=sha256:03038ac1cfbc41aa21f6afcbcd357281d7521b4157926f30ebecc8d4ea59dcb7 \
--hash=sha256:28545383d61f55b57cf4df63eebd9827754fd2dc25f80c5253f9184235db242c \
--hash=sha256:2e3427429c9cffebf259491be0af70189607f365c2f41c7c3764af6f337105f2 \
--hash=sha256:398a9e0c3eaceb34ec1aee71894ca3299605fa8e761544934378bbc6c97de23b \
--hash=sha256:44246bab5dd4b7fbd3c0c80b6f16686808fab0e4aca819ade6e8d294a29c7050 \
--hash=sha256:447d43819997825d4e71bf5769d869b968ce96848b6479397e29fc24c4a5dfe9 \
--hash=sha256:67a3598f0a2dcbc58d02dd1928544e7d88f764b47d4a286202913f0b2801c2e7 \
--hash=sha256:74480f79a023f90dc6e18febbf7b8bac7508420f2006fabd512013c0c238f454 \
--hash=sha256:819559cafa1a373b7096a482b504ae8a857c89593cf3a25af743ac9ecbd23480 \
--hash=sha256:899dc660cd599d7352d6f10d83c95df430a38b410c1b66b407a6b29265d66469 \
--hash=sha256:8c0c984a1b8fef4086329ff8dd19ac77576b384079247c770f29cc8ce3afa06c \
--hash=sha256:9aae4406ea63d825636cc11ffb34ad3379335803216ee3a856787bcf5ccc751e \
--hash=sha256:a7ca6d488aa8ff7f329d4c545b2dbad8ac31464f1d8b1c87ad1346717731e4db \
--hash=sha256:b6cc7ba72a8850621bfec987cb72623e703b7fe2b9127a161ce61e61558ad905 \
--hash=sha256:bf01b5720be110540be4286e791db73f84a2b721072a3711efff6c324cdf074b \
--hash=sha256:c02ce36ec760252242a33967d51c289fd0e1c0e6e5cc9397e2279177716add86 \
--hash=sha256:d9e4432ff660d67d775c66ac42a67cf2453c27cb4d738fc22cb53b5d84c135d4 \
--hash=sha256:daa564862dd0d39c00f8086f88700fdbe8bc717e993a21e90711acfed02f2402 \
--hash=sha256:de78575669dddf6099a8a0f46a27e82a1783c557ccc38ee620ed8cc96d3be7d7 \
--hash=sha256:e64857f395505ebf3d2569935506ae0dfc4a15cb80dc25261176c784662cdcc4 \
--hash=sha256:f4bd856d702e5b0d96a00ec6b307b0f51c1982c2bf9c0052cf9019e9a544ba99 \
--hash=sha256:f4c42102bc82a51108e449cbb32b19b180022941c727bac0cfd50170341f16ee
# via -r ./requirements.in
2 changes: 1 addition & 1 deletion examples/py_proto_library/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TestCase(unittest.TestCase):
def test_pricetag(self):
got = pricetag_pb2.Pricetag(
got = pricetag_pb2.PriceTag(
name="dollar",
cost=5.00,
)
Expand Down

0 comments on commit bd26d71

Please sign in to comment.