Skip to content

Commit 4dfdb67

Browse files
committed
build, tools, win: check if python is a executable program
After Windows 10 version 1903, placeholder files named "python.exe" and "python3.exe" appear, not executable programs, and open the MS Store when running without parameters. Fixes: #36694 Refs: https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update
1 parent 8cf5ae0 commit 4dfdb67

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/msvs/find_python.cmd

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ exit /b 1
4646

4747
:found-python
4848
echo Python found in %p%\python.exe
49+
call :check-python %p%\python.exe
50+
if errorlevel 1 goto :no-python
4951
endlocal ^
5052
& set "pt=%p%" ^
5153
& set "need_path_ext=%need_path%"
@@ -55,6 +57,15 @@ set "pt="
5557
set "need_path_ext="
5658
exit /b 0
5759

60+
:check-python
61+
%~1 -V
62+
:: 9009 means error file not found
63+
if %errorlevel% equ 9009 (
64+
echo Not a executable Python program
65+
exit /b 1
66+
)
67+
exit /b 0
68+
5869
:no-python
5970
echo Could not find Python.
6071
exit /b 1

0 commit comments

Comments
 (0)