fix: use KICAD_PYTHON env var instead of hardcoded Windows path

The Python executable and PYTHONPATH were hardcoded to Windows paths,
causing the server to fail silently on macOS/Linux. Now reads
KICAD_PYTHON from the environment (set by setup-macos.sh) with
python3 as the fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Samuel Price
2026-04-18 17:10:56 -04:00
parent 3d996427ee
commit 8ace3e4d24

View File

@@ -306,14 +306,13 @@ class KiCADServer {
// Start the Python process for KiCAD scripting
console.error(`Starting Python process with script: ${this.kicadScriptPath}`);
const pythonExe = "C:\\Program Files\\KiCad\\9.0\\bin\\python.exe";
const pythonExe = process.env.KICAD_PYTHON || "python3";
console.error(`Using Python executable: ${pythonExe}`);
this.pythonProcess = spawn(pythonExe, [this.kicadScriptPath], {
stdio: ["pipe", "pipe", "pipe"],
env: {
...process.env,
PYTHONPATH: "C:/Program Files/KiCad/9.0/lib/python3/dist-packages",
},
});