python: Move targets into pw_env_setup

Bug: 325
Change-Id: Ib9eaf2b594e21f12515a8a260fd7eb289b77b53a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/33822
Commit-Queue: Rob Mohr <mohrr@google.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 1399035..1d1e617 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -44,12 +44,12 @@
     ":docs",
     ":fuzzers",
     ":host",
-    ":python.install",
-    ":python.lint",
-    ":python.tests",
     ":stm32f429i",
-    ":target_support_packages.lint",
-    ":target_support_packages.tests",
+    "$dir_pw_env_setup:python.install",
+    "$dir_pw_env_setup:python.lint",
+    "$dir_pw_env_setup:python.tests",
+    "$dir_pw_env_setup:target_support_packages.lint",
+    "$dir_pw_env_setup:target_support_packages.tests",
   ]
 }
 
@@ -133,44 +133,14 @@
   }
 }
 
+# TODO(pwbug/325) Delete this target.
 pw_python_group("python") {
-  python_deps = [
-    # Python packages
-    "$dir_pw_allocator/py",
-    "$dir_pw_arduino_build/py",
-    "$dir_pw_bloat/py",
-    "$dir_pw_build/py",
-    "$dir_pw_cli/py",
-    "$dir_pw_cpu_exception_cortex_m/py",
-    "$dir_pw_docgen/py",
-    "$dir_pw_doctor/py",
-    "$dir_pw_env_setup/py",
-    "$dir_pw_hdlc/py",
-    "$dir_pw_module/py",
-    "$dir_pw_package/py",
-    "$dir_pw_presubmit/py",
-    "$dir_pw_protobuf/py",
-    "$dir_pw_protobuf_compiler/py",
-    "$dir_pw_rpc/py",
-    "$dir_pw_status/py",
-    "$dir_pw_tokenizer/py",
-    "$dir_pw_toolchain/py",
-    "$dir_pw_trace/py",
-    "$dir_pw_trace_tokenized/py",
-    "$dir_pw_unit_test/py",
-    "$dir_pw_watch/py",
-
-    # Standalone scripts
-    "$dir_pw_hdlc/rpc_example:example_script",
-  ]
+  python_deps = [ "$dir_pw_env_setup:python" ]
 }
 
-# Python packages for supporting specific targets.
+# TODO(pwbug/325) Delete this target.
 pw_python_group("target_support_packages") {
-  python_deps = [
-    "$dir_pigweed/targets/lm3s6965evb-qemu/py",
-    "$dir_pigweed/targets/stm32f429i-disc1/py",
-  ]
+  python_deps = [ "$dir_pw_env_setup:target_support_packages" ]
 }
 
 # By default, Pigweed will build this target when invoking ninja.
diff --git a/bootstrap.sh b/bootstrap.sh
index e430bf5..f0ee091 100644
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -89,7 +89,7 @@
 if [ "$(basename "$_BOOTSTRAP_PATH")" = "bootstrap.sh" ] || \
   [ ! -f "$SETUP_SH" ] || \
   [ ! -s "$SETUP_SH" ]; then
-  pw_bootstrap --shell-file "$SETUP_SH" --install-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT" --use-pigweed-defaults --json-file "$_PW_ACTUAL_ENVIRONMENT_ROOT/actions.json" --virtualenv-gn-out-dir "$PW_ROOT/out" --virtualenv-gn-target "$PW_ROOT#:target_support_packages.install"
+  pw_bootstrap --shell-file "$SETUP_SH" --install-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT" --use-pigweed-defaults --json-file "$_PW_ACTUAL_ENVIRONMENT_ROOT/actions.json" --virtualenv-gn-out-dir "$PW_ROOT/out" --virtualenv-gn-target "$PW_ROOT#pw_env_setup:target_support_packages.install"
   pw_finalize bootstrap "$SETUP_SH"
 else
   pw_activate
diff --git a/pw_env_setup/BUILD.gn b/pw_env_setup/BUILD.gn
index 2232988..e882151 100644
--- a/pw_env_setup/BUILD.gn
+++ b/pw_env_setup/BUILD.gn
@@ -14,9 +14,50 @@
 
 import("//build_overrides/pigweed.gni")
 
+import("$dir_pw_build/python.gni")
 import("$dir_pw_docgen/docs.gni")
 
 pw_doc_group("docs") {
   inputs = [ "doc_resources/pw_env_setup_output.png" ]
   sources = [ "docs.rst" ]
 }
+
+pw_python_group("python") {
+  python_deps = [
+    # Python packages
+    "$dir_pw_allocator/py",
+    "$dir_pw_arduino_build/py",
+    "$dir_pw_bloat/py",
+    "$dir_pw_build/py",
+    "$dir_pw_cli/py",
+    "$dir_pw_cpu_exception_cortex_m/py",
+    "$dir_pw_docgen/py",
+    "$dir_pw_doctor/py",
+    "$dir_pw_env_setup/py",
+    "$dir_pw_hdlc/py",
+    "$dir_pw_module/py",
+    "$dir_pw_package/py",
+    "$dir_pw_presubmit/py",
+    "$dir_pw_protobuf/py",
+    "$dir_pw_protobuf_compiler/py",
+    "$dir_pw_rpc/py",
+    "$dir_pw_status/py",
+    "$dir_pw_tokenizer/py",
+    "$dir_pw_toolchain/py",
+    "$dir_pw_trace/py",
+    "$dir_pw_trace_tokenized/py",
+    "$dir_pw_unit_test/py",
+    "$dir_pw_watch/py",
+
+    # Standalone scripts
+    "$dir_pw_hdlc/rpc_example:example_script",
+  ]
+}
+
+# Python packages for supporting specific targets.
+pw_python_group("target_support_packages") {
+  python_deps = [
+    "$dir_pigweed/targets/lm3s6965evb-qemu/py",
+    "$dir_pigweed/targets/stm32f429i-disc1/py",
+  ]
+}
diff --git a/pw_env_setup/py/pw_env_setup/env_setup.py b/pw_env_setup/py/pw_env_setup/env_setup.py
index 6eb3a00..4f4d445 100755
--- a/pw_env_setup/py/pw_env_setup/env_setup.py
+++ b/pw_env_setup/py/pw_env_setup/env_setup.py
@@ -220,7 +220,7 @@
                 os.path.join(setup_root, 'cipd_setup', 'luci.json'))
             self._virtualenv_gn_targets.append(
                 virtualenv_setup.GnTarget(
-                    '{}#:python.install'.format(pw_root)))
+                    '{}#pw_env_setup:python.install'.format(pw_root)))
             self._cargo_package_file.append(
                 os.path.join(setup_root, 'cargo_setup', 'packages.txt'))