fix(windows): add KiCad 10.0 bin/Lib/site-packages to Python path detection

KiCad 10.0 on Windows ships pcbnew.py under bin/Lib/site-packages rather
than the lib/python3/dist-packages path used by KiCad 9.x. Without this
path the MCP server's Python process fails to import pcbnew and exits
immediately with "Failed to import pcbnew module - KiCAD Python API not found".

Changes:
- Prioritise 10.0 in the version list so the newer path is checked first
- Add bin/Lib/site-packages check before the existing lib/python3/dist-packages
  check for every version, so both layouts are supported side-by-side

Note: the pcbnew extension is compiled against KiCad's bundled Python 3.11,
so callers must also set KICAD_PYTHON to the KiCad python.exe
(C:\Program Files\KiCad\10.0\bin\python.exe) to avoid a DLL version
conflict when the system Python differs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
TE603
2026-04-22 16:00:43 +09:00
parent 28d9f3353e
commit 1a14a45881

View File

@@ -59,7 +59,12 @@ class PlatformHelper:
]
for pf in program_files:
# Check multiple KiCAD versions
for version in ["9.0", "9.1", "10.0", "8.0"]:
for version in ["10.0", "9.0", "9.1", "8.0"]:
# KiCad 10.0+ Windows: bin/Lib/site-packages
path = pf / version / "bin" / "Lib" / "site-packages"
if path.exists():
paths.append(path)
# KiCad 9.x Windows: lib/python3/dist-packages
path = pf / version / "lib" / "python3" / "dist-packages"
if path.exists():
paths.append(path)