Skip to content

Commit 325813e

Browse files
jasonginMylesBorins
authored andcommitted
build,win: fix python detection script
Handle spaces in the path to python.exe, in case it is installed under some directory like "C:\Program Files". Backport-PR-URL: #14842 PR-URL: #14546 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent c2090a0 commit 325813e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tools/msvs/find_python.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ EXIT /B 1
4141
:validate
4242
IF NOT EXIST "%p%python.exe" EXIT /B 1
4343
:: Check if %p% is python2
44-
%p%python.exe -V 2>&1 | findstr /R "^Python.2.*" > NUL
44+
"%p%python.exe" -V 2>&1 | findstr /R "^Python.2.*" > NUL
4545
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%
4646
:: We can wrap it up
4747
ENDLOCAL & SET pt=%p%& SET need_path_ext=%need_path%

vcbuild.bat

+2-2
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ goto exit
378378
:run-python
379379
call tools\msvs\find_python.cmd
380380
if errorlevel 1 echo Could not find python2 & goto :exit
381-
set cmd1=%VCBUILD_PYTHON_LOCATION% %*
381+
set cmd1="%VCBUILD_PYTHON_LOCATION%" %*
382382
echo %cmd1%
383383
%cmd1%
384384
exit /b %ERRORLEVEL%
@@ -396,7 +396,7 @@ set TAG=
396396
set FULLVERSION=
397397
:: Call as subroutine for validation of python
398398
call :run-python tools\getnodeversion.py > nul
399-
for /F "tokens=*" %%i in ('%VCBUILD_PYTHON_LOCATION% tools\getnodeversion.py') do set NODE_VERSION=%%i
399+
for /F "tokens=*" %%i in ('"%VCBUILD_PYTHON_LOCATION%" tools\getnodeversion.py') do set NODE_VERSION=%%i
400400
if not defined NODE_VERSION (
401401
echo Cannot determine current version of Node.js
402402
exit /b 1

0 commit comments

Comments
 (0)