From 678628bcb97e6790014abdaa6b49133bf56fb5cc Mon Sep 17 00:00:00 2001 From: Morgan Funtowicz Date: Thu, 23 Oct 2025 11:42:29 +0200 Subject: [PATCH] feat(windows): allow detecting Python executable --- scripts/windows/builder.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/windows/builder.ps1 b/scripts/windows/builder.ps1 index 1e79c7fc..bf0e0618 100644 --- a/scripts/windows/builder.ps1 +++ b/scripts/windows/builder.ps1 @@ -330,6 +330,21 @@ function Get-CMakeConfigureArgs { $kwargs = @("..", "-G", "Visual Studio 17 2022", "-A", $vsArch) + # Detect Python from current environment + $pythonExe = (Get-Command python -ErrorAction SilentlyContinue).Source + if ($pythonExe) { + $kwargs += "-DPython3_EXECUTABLE=$pythonExe" + Write-Status "Using Python from environment: $pythonExe" -Type Info + + # Verify Python and PyTorch version + $torchVersion = & $pythonExe -c "import torch; print(torch.__version__)" 2>$null + if ($torchVersion) { + Write-Status "Detected PyTorch version: $torchVersion" -Type Info + } + } else { + Write-Status "Python not found in PATH, CMake will auto-detect" -Type Warning + } + if ($ShouldInstall -and $InstallPrefix) { $kwargs += "-DCMAKE_INSTALL_PREFIX=$InstallPrefix" Write-Status "Setting CMAKE_INSTALL_PREFIX=$InstallPrefix" -Type Info