Skip to content

Commit

Permalink
Adjust subprocess env passing
Browse files Browse the repository at this point in the history
  • Loading branch information
ncoghlan committed Oct 23, 2024
1 parent 4cf6f9d commit b0352ba
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/venvstacks/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from contextlib import contextmanager
from pathlib import Path
from typing import Any, Generator
from typing import Any, Generator, Mapping

WINDOWS_BUILD = hasattr(os, "add_dll_directory")

Expand Down Expand Up @@ -78,23 +78,24 @@ def get_env_python(env_path: Path) -> Path:


def run_python_command_unchecked(
# Narrow list/dict type specs here due to the way `subprocess.run` params are typed
# Narrow list type spec here due to the way `subprocess.run` params are typed
command: list[str],
*,
env: dict[str, str] | None = None,
env: Mapping[str, str] | None = None,
**kwds: Any,
) -> subprocess.CompletedProcess[str]:
if env is None:
env = os.environ.copy()
env.update(_SUBPROCESS_PYTHON_CONFIG)
run_env = os.environ.copy()
if env is not None:
run_env.update(env)
run_env.update(_SUBPROCESS_PYTHON_CONFIG)
result: subprocess.CompletedProcess[str] = subprocess.run(
command, env=env, text=True, **kwds
)
return result


def run_python_command(
# Narrow list/dict type specs here due to the way `subprocess.run` params are typed
# Narrow list type spec here due to the way `subprocess.run` params are typed
command: list[str],
**kwds: Any,
) -> subprocess.CompletedProcess[str]:
Expand Down

0 comments on commit b0352ba

Please sign in to comment.