Skip to content

Commit 8980d8c

Browse files
joaocgreistargos
authored andcommitted
build: vcbuild uses default Python, not Py2
vcbuild now searches for the first python.exe found, and uses it, where it used to look for Python 2 first. PR-URL: #30091 Reviewed-By: Christian Clauss <[email protected]> Reviewed-By: João Reis <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent cedad02 commit 8980d8c

File tree

2 files changed

+1
-54
lines changed

2 files changed

+1
-54
lines changed

tools/msvs/find_python.cmd

+1-51
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,6 @@
33
echo Looking for Python
44
setlocal enabledelayedexpansion
55

6-
:: To remove the preference for Python 2, but still support it, just remove
7-
:: the 5 blocks marked with "Python 2:" and the support warnings
8-
9-
:: Python 2: If python.exe is in %Path%, use if it's Python 2
10-
FOR /F "delims=" %%a IN ('where python.exe 2^> NUL') DO (
11-
SET need_path=0
12-
SET p=%%~dpa
13-
CALL :validate-v2
14-
IF NOT ERRORLEVEL 1 GOTO :found-python2
15-
GOTO :done-path-v2
16-
)
17-
:done-path-v2
18-
19-
:: Python 2: Query the 3 locations mentioned in PEP 514 for a python2 InstallPath
20-
FOR %%K IN ( "HKCU\Software", "HKLM\SOFTWARE", "HKLM\Software\Wow6432Node") DO (
21-
SET need_path=1
22-
CALL :find-versions-v2 %%K
23-
IF NOT ERRORLEVEL 1 CALL :validate-v2
24-
IF NOT ERRORLEVEL 1 GOTO :found-python2
25-
)
26-
276
:: Use python.exe if in %PATH%
287
set need_path=0
298
for /f "delims=" %%a in ('where python.exe 2^> nul') do (
@@ -41,14 +20,6 @@ for %%k in ( "HKCU\Software", "HKLM\SOFTWARE", "HKLM\Software\Wow6432Node") do (
4120
goto :no-python
4221

4322

44-
:: Python 2: Find Python 2 installations in a registry location
45-
:find-versions-v2
46-
for /f "delims=" %%a in ('reg query "%~1\Python\PythonCore" /f * /k 2^> nul ^| findstr /r ^^HK ^| findstr "\\2\."') do (
47-
call :read-installpath %%a
48-
if not errorlevel 1 exit /b 0
49-
)
50-
exit /b 1
51-
5223
:: Find Python installations in a registry location
5324
:find-versions
5425
for /f "delims=" %%a in ('reg query "%~1\Python\PythonCore" /f * /k 2^> nul ^| findstr /r ^^HK') do (
@@ -73,32 +44,11 @@ for /f "skip=2 tokens=1* delims=)" %%a in ('reg query "%1\InstallPath" /ve /t RE
7344
)
7445
exit /b 1
7546

76-
77-
:: Python 2: Check if %p% holds a path to a real python2 executable
78-
:validate-v2
79-
IF NOT EXIST "%p%\python.exe" EXIT /B 1
80-
:: Check if %p% is python2
81-
"%p%\python.exe" -V 2>&1 | findstr /R "^Python.2.*" > NUL
82-
EXIT /B %ERRORLEVEL%
83-
84-
85-
:: Python 2:
86-
:found-python2
87-
echo Python 2 found in %p%\python.exe
88-
set pyver=2
89-
goto :done
90-
9147
:found-python
9248
echo Python found in %p%\python.exe
93-
echo WARNING: Python 3 is not yet fully supported, to avoid issues Python 2 should be installed.
94-
set pyver=3
95-
goto :done
96-
97-
:done
9849
endlocal ^
9950
& set "pt=%p%" ^
100-
& set "need_path_ext=%need_path%" ^
101-
& set "VCBUILD_PYTHON_VERSION=%pyver%"
51+
& set "need_path_ext=%need_path%"
10252
set "VCBUILD_PYTHON_LOCATION=%pt%\python.exe"
10353
if %need_path_ext%==1 set "PATH=%pt%;%PATH%"
10454
set "pt="

vcbuild.bat

-3
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,6 @@ goto exit
688688

689689
:create-msvs-files-failed
690690
echo Failed to create vc project files.
691-
if %VCBUILD_PYTHON_VERSION%==3 (
692-
echo Python 3 is not yet fully supported, to avoid issues Python 2 should be installed.
693-
)
694691
del .used_configure_flags
695692
goto exit
696693

0 commit comments

Comments
 (0)