From 6c93e5ba6dbf1d9cfe5843c670ebdb3a87dd5002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 3 Sep 2019 16:44:50 +0100 Subject: [PATCH 1/2] build,win: fix Python detection on localized OS This code previously assumed the default value was always printed to the console by reg.exe as "(default)", but this is not true on localized versions of Windows and can contain spaces. Fixes: https://github.com/nodejs/node/issues/29417 --- tools/msvs/find_python.cmd | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/msvs/find_python.cmd b/tools/msvs/find_python.cmd index cb98f9df432901..728eeb405b8171 100644 --- a/tools/msvs/find_python.cmd +++ b/tools/msvs/find_python.cmd @@ -60,14 +60,16 @@ exit /b 1 :: Read the InstallPath of a given Environment Key to %p% :: https://www.python.org/dev/peps/pep-0514/#installpath :read-installpath -:: %%a will receive token 3 -:: %%b will receive *, corresponding to token 4 and all after -for /f "skip=2 tokens=3*" %%a in ('reg query "%1\InstallPath" /ve /t REG_SZ 2^> nul') do ( - set "head=%%a" - set "tail=%%b" - set "p=!head!" - if not "!tail!"=="" set "p=!head! !tail!" - exit /b 0 +:: %%a will receive everything before ), might have spaces depending on language +:: %%b will receive *, corresponding to everything after ) +:: %%c will receive REG_SZ +:: %%d will receive the path, including spaces +for /f "skip=2 tokens=1* delims=)" %%a in ('reg query "%1\InstallPath" /ve /t REG_SZ 2^> nul') do ( + for /f "tokens=1*" %%c in ("%%b") do ( + if not "%%c"=="REG_SZ" exit /b 1 + set "p=%%d" + exit /b 0 + ) ) exit /b 1 From d372475a3975eb80c2ac885186f5b6f124cfaaf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 3 Sep 2019 17:55:43 +0100 Subject: [PATCH 2/2] fixup! build,win: fix Python detection on localized OS --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index fa5162684b8dc8..9f7d9377eaf426 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ test/fixtures/* -text vcbuild.bat text eol=crlf +tools/msvs/find_python.cmd text eol=crlf