pw_build: Lint & test deps in python_dist.gni templates

The pw_create_python_source_tree and pw_internal_pip_install templates
can be used as python_deps, but their lint and test subtargets do
nothing instead of forwarding to their packages. This would make it easy
to accidentally stop linting and testing a bunch of packages.

Update these templates so their subtargets forward to a pw_python_group
of their packages.

Change-Id: I7f0e27bf4577a6779f310343ff3a8c21a86af2da
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/97443
Reviewed-by: Armando Montanez <amontanez@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
diff --git a/pw_build/python_dist.gni b/pw_build/python_dist.gni
index 9e8dfeb..8d32956 100644
--- a/pw_build/python_dist.gni
+++ b/pw_build/python_dist.gni
@@ -338,19 +338,26 @@
     public_deps = [ ":${invoker.target_name}._build_wheel" ]
   }
 
-  # Stub target groups to match a pw_python_package. This lets $target_name be
-  # used as a python_dep in pw_python_group.
-  group("$target_name.install") {
+  # Allow using pw_create_python_source_tree targets as a python_dep in
+  # pw_python_group. To do this, create a pw_python_group with the relevant
+  # packages and create wrappers for each subtarget, except those that are
+  # actually implemented by this template.
+  #
+  # This is an ugly workaround that will be removed when the Python build is
+  # refactored (b/235278298).
+  pw_python_group("$target_name._pw_python_group") {
+    python_deps = invoker.packages
   }
-  group("$target_name._run_pip_install") {
-  }
-  group("$target_name.lint") {
-  }
-  group("$target_name.lint.mypy") {
-  }
-  group("$target_name.lint.pylint") {
-  }
-  group("$target_name.tests") {
+
+  wrapped_subtargets = pw_python_package_subtargets - [
+                         "wheel",
+                         "_build_wheel",
+                       ]
+
+  foreach(subtarget, wrapped_subtargets) {
+    group("$target_name.$subtarget") {
+      public_deps = [ ":${invoker.target_name}._pw_python_group.$subtarget" ]
+    }
   }
 }
 
@@ -456,23 +463,24 @@
     not_needed(invoker, "*")
   }
 
-  # Stub target groups to match a pw_python_package. This lets $target_name be
-  # used as a python_dep in pw_python_group.
   group("$target_name.install") {
     public_deps = [ ":${invoker.target_name}" ]
   }
-  group("$target_name._run_pip_install") {
+
+  # Allow using pw_internal_pip_install targets as a python_dep in
+  # pw_python_group. To do this, create a pw_python_group with the relevant
+  # packages and create wrappers for each subtarget, except those that are
+  # actually implemented by this template.
+  #
+  # This is an ugly workaround that will be removed when the Python build is
+  # refactored (b/235278298).
+  pw_python_group("$target_name._pw_python_group") {
+    python_deps = invoker.packages
   }
-  group("$target_name.wheel") {
-  }
-  group("$target_name._build_wheel") {
-  }
-  group("$target_name.lint") {
-  }
-  group("$target_name.lint.mypy") {
-  }
-  group("$target_name.lint.pylint") {
-  }
-  group("$target_name.tests") {
+
+  foreach(subtarget, pw_python_package_subtargets - [ "install" ]) {
+    group("$target_name.$subtarget") {
+      public_deps = [ ":${invoker.target_name}._pw_python_group.$subtarget" ]
+    }
   }
 }