diff --git a/compute_endpoint/globus_compute_endpoint/cli.py b/compute_endpoint/globus_compute_endpoint/cli.py index 4bcda0731..cd79408b1 100644 --- a/compute_endpoint/globus_compute_endpoint/cli.py +++ b/compute_endpoint/globus_compute_endpoint/cli.py @@ -5,10 +5,10 @@ import gzip import json import logging +import os import pathlib import re import shutil -import subprocess import sys import textwrap import uuid @@ -924,7 +924,7 @@ def run_python_executable(ctx: click.Context, module: str): E.g., globus-compute-endpoint python-exec path.to.module --ahoy matey """ - subprocess.run([sys.executable, "-m", module] + ctx.args) + os.execvpe(sys.executable, [sys.executable, "-m", module] + ctx.args, os.environ) def create_or_choose_auth_project(ac: AuthClient) -> str: diff --git a/compute_endpoint/tests/unit/test_cli_behavior.py b/compute_endpoint/tests/unit/test_cli_behavior.py index 783a4f849..08e2a2e88 100644 --- a/compute_endpoint/tests/unit/test_cli_behavior.py +++ b/compute_endpoint/tests/unit/test_cli_behavior.py @@ -808,10 +808,12 @@ def run_cmd(): def test_python_exec(mocker: MockFixture, run_line: t.Callable): - mock_subprocess_run = mocker.patch("subprocess.run") + mock_execvpe = mocker.patch("os.execvpe") run_line("python-exec path.to.module arg --option val") - mock_subprocess_run.assert_called_with( - [sys.executable, "-m", "path.to.module", "arg", "--option", "val"] + mock_execvpe.assert_called_with( + sys.executable, + [sys.executable, "-m", "path.to.module", "arg", "--option", "val"], + os.environ, )