pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/nodejs/node/commit/d5c9b09bdc7cafebeb8e00948bbdce6c53fafc89

mer-b69241e157469407.css" /> build,win: find Python in paths with spaces · nodejs/node@d5c9b09 · GitHub
Skip to content

Commit d5c9b09

Browse files
joaocgreisrichardlau
authored andcommitted
build,win: find Python in paths with spaces
When looking for Python in the registry, as specified in PEP514, this was not able to handle installations in a path with spaces, like Program Files. This ensures the whole path is used, fixing the issue. PR-URL: #29236 Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 9c49707 commit d5c9b09

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

tools/msvs/find_python.cmd

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@IF NOT DEFINED DEBUG_HELPER @ECHO OFF
2+
23
echo Looking for Python 2.x
3-
SETLOCAL
4+
setlocal enabledelayedexpansion
5+
46
:: If python.exe is in %Path%, just validate
57
FOR /F "delims=" %%a IN ('where python.exe 2^> NUL') DO (
68
SET need_path=0
@@ -11,32 +13,36 @@ FOR /F "delims=" %%a IN ('where python.exe 2^> NUL') DO (
1113
:: Query the 3 locations mentioned in PEP 514 for a python2 InstallPath
1214
FOR %%K IN ( "HKCU\Software", "HKLM\SOFTWARE", "HKLM\Software\Wow6432Node") DO (
1315
SET need_path=1
14-
CALL :find-main-branch %%K
16+
CALL :find-versions-v2 %%K
1517
:: If validate returns 0 just jump to the end
1618
IF NOT ERRORLEVEL 1 GOTO :validate
1719
)
20+
1821
goto :no-python
1922

20-
:: Helper subroutine to handle quotes in %1
21-
:find-main-branch
22-
SET main_key="%~1\Python\PythonCore"
23-
REG QUERY %main_key% /s 2> NUL | findstr "2." | findstr InstallPath > NUL 2> NUL
24-
IF NOT ERRORLEVEL 1 CALL :find-key %main_key%
25-
EXIT /B
26-
27-
:: Query registry sub-tree for InstallPath
28-
:find-key
29-
FOR /F "delims=" %%a IN ('REG QUERY %1 /s 2^> NUL ^| findstr "2." ^| findstr InstallPath') DO IF NOT ERRORLEVEL 1 CALL :find-path %%a
30-
EXIT /B
31-
32-
:: Parse the value of %1 as the path for python.exe
33-
:find-path
34-
FOR /F "tokens=3*" %%a IN ('REG QUERY %1 /ve') DO (
35-
SET pt=%%a
36-
IF NOT ERRORLEVEL 1 SET p=%pt%
37-
EXIT /B 0
23+
24+
:: Find Python 2 installations in a registry location
25+
:find-versions-v2
26+
for /f "delims=" %%a in ('reg query "%~1\Python\PythonCore" /f * /k 2^> nul ^| findstr /r ^^HK ^| findstr "\\2\."') do (
27+
call :read-installpath %%a
28+
if not errorlevel 1 exit /b 0
3829
)
39-
EXIT /B 1
30+
exit /b 1
31+
32+
:: Read the InstallPath of a given Environment Key to %p%
33+
:: https://www.python.org/dev/peps/pep-0514/#installpath
34+
:read-installpath
35+
:: %%a will receive token 3
36+
:: %%b will receive *, corresponding to token 4 and all after
37+
for /f "skip=2 tokens=3*" %%a in ('reg query "%1\InstallPath" /ve /t REG_SZ 2^> nul') do (
38+
set "head=%%a"
39+
set "tail=%%b"
40+
set "p=!head!"
41+
if not "!tail!"=="" set "p=!head! !tail!"
42+
exit /b 0
43+
)
44+
exit /b 1
45+
4046

4147
:: Check if %p% holds a path to a real python2 executable
4248
:validate

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy