pw_env_setup: No extra virtualenv GN targets
Specifying --virtualenv-gn-out-dir causes undefined behavior when
multiple --virtualenv-gn-target flags are specified. This change makes
it so only one virtualenv GN target can be specificied.
If a virtualenv GN target is provided, pigweed will no longer provide
its own python virtualenv target when --use-pigweed-defaults is in use.
This means projects must manually explicitly list Pigweed's python
modules as dependencies in their project.
Bug: 325
Change-Id: I323929fa803b91816d043b2df4521f5e04ce295d
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/33600
Reviewed-by: Rob Mohr <mohrr@google.com>
Commit-Queue: Armando Montanez <amontanez@google.com>
diff --git a/bootstrap.bat b/bootstrap.bat
index 29146b6..4ef0023 100644
--- a/bootstrap.bat
+++ b/bootstrap.bat
@@ -112,7 +112,8 @@
--shell-file "%shell_file%" ^
--install-dir "%_PW_ACTUAL_ENVIRONMENT_ROOT%" ^
--use-pigweed-defaults ^
- --virtualenv-gn-target "%PW_ROOT%#:target_support_packages.install" ^
+ --virtualenv-gn-target "%PW_ROOT%#pw_env_setup:python.install" ^
+ --virtualenv-gn-target "%PW_ROOT%#pw_env_setup:target_support_packages.install" ^
--project-root "%PW_PROJECT_ROOT%"
goto activate_shell
diff --git a/bootstrap.sh b/bootstrap.sh
index f0ee091..06c427b 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#pw_env_setup: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:python.install" --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/py/pw_env_setup/env_setup.py b/pw_env_setup/py/pw_env_setup/env_setup.py
index 4f4d445..6e17bae 100755
--- a/pw_env_setup/py/pw_env_setup/env_setup.py
+++ b/pw_env_setup/py/pw_env_setup/env_setup.py
@@ -218,9 +218,11 @@
os.path.join(setup_root, 'cipd_setup', 'pigweed.json'))
self._cipd_package_file.append(
os.path.join(setup_root, 'cipd_setup', 'luci.json'))
- self._virtualenv_gn_targets.append(
- virtualenv_setup.GnTarget(
- '{}#pw_env_setup:python.install'.format(pw_root)))
+ # Only set if no other GN target is provided.
+ if not self._virtualenv_gn_targets:
+ self._virtualenv_gn_targets.append(
+ virtualenv_setup.GnTarget(
+ '{}#pw_env_setup:python.install'.format(pw_root)))
self._cargo_package_file.append(
os.path.join(setup_root, 'cargo_setup', 'packages.txt'))