From 1789357a08de80d7efd293bdb9015d84d3ad86bd Mon Sep 17 00:00:00 2001 From: Stuart Axelbrooke Date: Wed, 6 Aug 2025 17:04:39 -0700 Subject: [PATCH] Fix py_proto generation for submodules --- databuild/BUILD.bazel | 9 +++++++-- examples/podcast_reviews/MODULE.bazel | 4 ++-- examples/podcast_reviews/requirements_lock.txt | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/databuild/BUILD.bazel b/databuild/BUILD.bazel index 5048770..0e6b713 100644 --- a/databuild/BUILD.bazel +++ b/databuild/BUILD.bazel @@ -169,10 +169,15 @@ genrule( "py_proto_out/message_pool.py", ], cmd = """ -mkdir -p $(GENDIR)/databuild/py_proto_out +mkdir -p $(@D) export PATH=$$PATH:$$(dirname $(location :protoc-gen-python_betterproto2)) export PATH=$$PATH:$$(dirname $(location //:ruff_binary)) -$(location @com_google_protobuf//:protoc) --python_betterproto2_out=$(GENDIR)/databuild/py_proto_out $(location databuild.proto) +$(location @com_google_protobuf//:protoc) --python_betterproto2_out=$(@D) $(location databuild.proto) +mkdir -p $(@D)/py_proto_out/databuild/v1 +cp $(@D)/databuild/__init__.py $(@D)/py_proto_out/__init__.py +cp $(@D)/databuild/__init__.py $(@D)/py_proto_out/databuild/__init__.py +cp $(@D)/databuild/v1/__init__.py $(@D)/py_proto_out/databuild/v1/__init__.py +cp $(@D)/message_pool.py $(@D)/py_proto_out/message_pool.py """, tools = [ ":protoc-gen-python_betterproto2", diff --git a/examples/podcast_reviews/MODULE.bazel b/examples/podcast_reviews/MODULE.bazel index 438cadc..43c0009 100644 --- a/examples/podcast_reviews/MODULE.bazel +++ b/examples/podcast_reviews/MODULE.bazel @@ -14,13 +14,13 @@ bazel_dep(name = "rules_python", version = "1.3.0") python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( - python_version = "3.13", + python_version = "3.12", ) pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") pip.parse( hub_name = "pypi", - python_version = "3.13", + python_version = "3.12", requirements_lock = "//:requirements_lock.txt", ) use_repo(pip, "pypi") diff --git a/examples/podcast_reviews/requirements_lock.txt b/examples/podcast_reviews/requirements_lock.txt index e721309..0d03836 100644 --- a/examples/podcast_reviews/requirements_lock.txt +++ b/examples/podcast_reviews/requirements_lock.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.13 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # bazel run //:py_requirements.update