Runs a `python` process from an extracted PBS distribution. This function attempts to isolate the spawned interpreter from any external interference (PYTHON* environment variables), etc.
(
dist_root: Path,
python_info,
args: list[str],
extra_env: Optional[dict[str, str]] = None,
**runargs,
)
| 14 | |
| 15 | |
| 16 | def run_dist_python( |
| 17 | dist_root: Path, |
| 18 | python_info, |
| 19 | args: list[str], |
| 20 | extra_env: Optional[dict[str, str]] = None, |
| 21 | **runargs, |
| 22 | ) -> subprocess.CompletedProcess[str]: |
| 23 | """Runs a `python` process from an extracted PBS distribution. |
| 24 | |
| 25 | This function attempts to isolate the spawned interpreter from any |
| 26 | external interference (PYTHON* environment variables), etc. |
| 27 | """ |
| 28 | env = dict(os.environ) |
| 29 | |
| 30 | # Wipe PYTHON environment variables. |
| 31 | for k in list(env): |
| 32 | if k.startswith("PYTHON"): |
| 33 | del env[k] |
| 34 | |
| 35 | if extra_env: |
| 36 | env.update(extra_env) |
| 37 | |
| 38 | return subprocess.run( |
| 39 | [str(dist_root / python_info["python_exe"])] + args, |
| 40 | cwd=dist_root, |
| 41 | env=env, |
| 42 | **runargs, |
| 43 | ) |
| 44 | |
| 45 | |
| 46 | def run_custom_unittests(pbs_source_dir: Path, dist_root: Path, python_info) -> int: |
no test coverage detected