build: improve reliability of find_python.cmd script

The path of the Python executable might contain white spaces. Handle
this when the `check-python` function is called.

Fixes: https://github.com/nodejs/node/issues/42801

PR-URL: https://github.com/nodejs/node/pull/42810
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Luigi Pinca 2022-04-23 21:45:27 +02:00 committed by GitHub
parent 603803ecb7
commit e2ff1c3b2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,7 +46,7 @@ exit /b 1
:found-python
echo Python found in %p%\python.exe
call :check-python %p%\python.exe
call :check-python "%p%\python.exe"
if errorlevel 1 goto :no-python
endlocal ^
& set "pt=%p%" ^
@ -57,7 +57,7 @@ set "need_path_ext="
exit /b 0
:check-python
%~1 -V
%1 -V
:: 9009 means error file not found
if %errorlevel% equ 9009 (
echo Not an executable Python program