From 69c47578a5388c28ba4a5cace6ed253c501893ed Mon Sep 17 00:00:00 2001 From: Ruomio <1065940593@qq.com> Date: Mon, 26 Jan 2026 20:52:19 +0800 Subject: [PATCH] fix(python_path): ensure child process uses same Python path as parent * Fix issue where child process fallback to system Python path (/bin/python3) * Root cause: os/subprocess calls in script use system PATH instead of venv * Solution: inherit parent's Python path (sys.executable) to avoid path drift --- perf/ci-perf-compare.py | 3 ++- perf/server.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/perf/ci-perf-compare.py b/perf/ci-perf-compare.py index 03463d1..c4019d5 100644 --- a/perf/ci-perf-compare.py +++ b/perf/ci-perf-compare.py @@ -24,6 +24,7 @@ new_test = log_new_path + "/" + test old_test = log_old_path + "/" + test - cmd = f"python3 perf.py \'{old_test}\' \'{new_test}\' -o \'{output_path+test_name}.csv\'" + # Use sys.executable to ensure the same Python interpreter (venv) is used + cmd = f"{sys.executable} perf.py \'{old_test}\' \'{new_test}\' -o \'{output_path+test_name}.csv\'" #print(cmd) os.system(cmd) diff --git a/perf/server.py b/perf/server.py index 1e39f71..3f46db0 100644 --- a/perf/server.py +++ b/perf/server.py @@ -1,4 +1,5 @@ import os +import sys import subprocess import time import ast @@ -29,7 +30,7 @@ def numactl(self, cmd, mem, start, end, num_cores): def remote_get_free_cores(self, threads): pwd = os.path.dirname(os.path.abspath(__file__)) - cmd = ["python3", f"{pwd}/get_free_core.py", f"{threads}"] + cmd = [sys.executable, f"{pwd}/get_free_core.py", f"{threads}"] ssh_cmd_str = " ".join(self.remote_cmd + cmd) # print(ssh_cmd_str) proc = os.popen(ssh_cmd_str) @@ -221,7 +222,7 @@ def stop(self): # os.killpg(os.getpgid(proc[1].pid), signal.SIGINT) # kill emu by ssh kill 'emu.pid' pwd = os.path.dirname(os.path.abspath(__file__)) - os.popen(" ".join(self.remote_cmd) + f" python3 {pwd}/stop_emu.py") + os.popen(" ".join(self.remote_cmd) + f" {sys.executable} {pwd}/stop_emu.py") def is_epyc(self, num_cores): return num_cores > 16