From 8d33e5cb223b54f830acffaa52c13ed16245bb98 Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Tue, 7 Jan 2025 11:01:03 +0000 Subject: [PATCH] don't include PEX env vars with the SCIE --- .../backend/python/util_rules/pex_cli.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/python/pants/backend/python/util_rules/pex_cli.py b/src/python/pants/backend/python/util_rules/pex_cli.py index 0f81c35bf24..244e0268470 100644 --- a/src/python/pants/backend/python/util_rules/pex_cli.py +++ b/src/python/pants/backend/python/util_rules/pex_cli.py @@ -276,17 +276,22 @@ async def setup_pex_cli_process( complete_pex_env = pex_env.in_sandbox(working_directory=None) normalized_argv: tuple[str, ...] if pex_cli_tool.is_scie: + # TODO: Is there a neeed to select `pex3`? normalized_argv = (pex_cli_tool.exe, "pex", *args) else: normalized_argv = complete_pex_env.create_argv(pex_cli_tool.exe, *args) - env = { - **complete_pex_env.environment_dict(python=bootstrap_python), - **python_native_code.subprocess_env_vars, - **(request.extra_env or {}), # type: ignore[dict-item] - # If a subcommand is used, we need to use the `pex3` console script. - **({"PEX_SCRIPT": "pex3"} if request.subcommand else {}), - } + # Build the environment for running the program. + env = {} + if not pex_cli_tool.is_scie: + env.update(complete_pex_env.environment_dict(python=bootstrap_python)) + env.update(python_native_code.subprocess_env_vars) + if request.extra_env: + env.update(request.extra_env) # type: ignore[dict-item] + + # If a subcommand is used, we need to use the `pex3` console script. + if request.subcommand: + env["PEX_SCRIPT"] = "pex3" # TODO: This may require selecting "pex3" from the SCIE instead. return Process( normalized_argv,