pw_protobuf_compiler: Avoid duplicate protobuf Python packages

For compatibility with Python packaging, each pw_protobuf_library target
must have a unique root directory for its protos. If this is violated,
the setup.py for the Python package is generated multiple times,
resulting in flaky builds.

This change ensures that no two pw_proto_library targets generate the
same Python package and fixes existing conflicts in the Pigweed repo.

Change-Id: Icbc13ceeb2fd329bc4fbf1e14ec039e98dc7e483
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/31740
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_rpc/BUILD.gn b/pw_rpc/BUILD.gn
index 3e34b38..f25a335 100644
--- a/pw_rpc/BUILD.gn
+++ b/pw_rpc/BUILD.gn
@@ -16,6 +16,7 @@
 
 import("$dir_pw_bloat/bloat.gni")
 import("$dir_pw_build/module_config.gni")
+import("$dir_pw_build/python.gni")
 import("$dir_pw_build/python_action.gni")
 import("$dir_pw_build/target_types.gni")
 import("$dir_pw_docgen/docs.gni")
@@ -132,19 +133,23 @@
 }
 
 pw_proto_library("protos") {
-  sources = [ "pw_rpc_protos/packet.proto" ]
+  sources = [
+    "pw_rpc_protos/echo.proto",
+    "pw_rpc_protos/internal/packet.proto",
+  ]
+  inputs = [ "pw_rpc_protos/echo.options" ]
 }
 
-pw_proto_library("echo_service_proto") {
-  sources = [ "pw_rpc_protos/echo.proto" ]
-  inputs = [ "pw_rpc_protos/echo.options" ]
+# TODO(hepler): Remove this compatibility wrapper.
+pw_python_group("echo_service_proto.python") {
+  python_deps = [ ":protos.python" ]
 }
 
 pw_doc_group("docs") {
   sources = [ "docs.rst" ]
   inputs = [
     "pw_rpc_protos/echo.proto",
-    "pw_rpc_protos/packet.proto",
+    "pw_rpc_protos/internal/packet.proto",
   ]
   group_deps = [ "nanopb:docs" ]
   report_deps = [ ":server_size" ]