Skip to content

Commit 16b0676

Browse files
committed
fixed env for subprocess
1 parent 9fe888c commit 16b0676

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

codeflash/benchmarking/trace_benchmarks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
import re
45
import subprocess
56
from pathlib import Path
@@ -9,6 +10,11 @@
910

1011

1112
def trace_benchmarks_pytest(benchmarks_root: Path, tests_root:Path, project_root: Path, trace_file: Path, timeout:int = 300) -> None:
13+
benchmark_env = os.environ.copy()
14+
if "PYTHONPATH" not in benchmark_env:
15+
benchmark_env["PYTHONPATH"] = str(project_root)
16+
else:
17+
benchmark_env["PYTHONPATH"] += os.pathsep + str(project_root)
1218
result = subprocess.run(
1319
[
1420
SAFE_SYS_EXECUTABLE,
@@ -21,7 +27,7 @@ def trace_benchmarks_pytest(benchmarks_root: Path, tests_root:Path, project_root
2127
check=False,
2228
capture_output=True,
2329
text=True,
24-
env={"PYTHONPATH": str(project_root)},
30+
env=benchmark_env,
2531
timeout=timeout,
2632
)
2733
if result.returncode != 0:

0 commit comments

Comments
 (0)