blob: ecea1f7fb8068d775d555befd3451da08577fb99 [file] [log] [blame]
Alexander Afanasyeve3342152016-03-20 11:23:57 -07001@echo off
2
3rem from issue #964
4
5Setlocal EnableDelayedExpansion
6
7rem Check Windows Version
8set TOKEN=tokens=3*
9ver | findstr /i "5\.0\." > nul
10if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
11ver | findstr /i "5\.1\." > nul
12if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
13ver | findstr /i "5\.2\." > nul
14if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
15ver | findstr /i "6\.0\." > nul
16if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=2*
17ver | findstr /i "6\.1\." > nul
18if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=2*
19
20rem Start calculating PYTHON and PYTHON_DIR
21set PYTHON=
22set PYTHON_DIR=
23
24Setlocal EnableDelayedExpansion
25
26set PYTHON_DIR_OK=FALSE
27set REGPATH=
28
29for %%i in (3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5 2.4 2.3) do (
30for %%j in (HKCU HKLM) do (
31for %%k in (SOFTWARE\Wow6432Node SOFTWARE) do (
32for %%l in (Python\PythonCore IronPython) do (
33set REG_PYTHON_EXE=python.exe
34if "%%l"=="IronPython" (
35set REG_PYTHON_EXE=ipy.exe
36)
37
38@echo on
39
40set REGPATH=%%j\%%k\%%l\%%i\InstallPath
41rem @echo Regpath !REGPATH!
42REG QUERY "!REGPATH!" /ve 1>nul 2>nul
43if !ERRORLEVEL! equ 0 (
44 for /F "%TOKEN% delims= " %%A IN ('REG QUERY "!REGPATH!" /ve') do @set REG_PYTHON_DIR=%%B
45 if exist !REG_PYTHON_DIR! (
46 set REG_PYTHON=!REG_PYTHON_DIR!!REG_PYTHON_EXE!
47 rem set PYTHON_DIR_OK=TRUE
48 if "!PYTHON_DIR_OK!"=="FALSE" (
49 set PYTHON_DIR=!REG_PYTHON_DIR!
50 set PYTHON=!REG_PYTHON!
51 set PYTHON_DIR_OK=TRUE
52 )
53
54 rem set PYTHON_DIR_OK=FALSE
55 rem @echo Find !REG_PYTHON!
56 rem goto finished
57 )
58)
59
60echo off
61
62)
63rem for l
64)
65rem for k
66)
67rem for j
68)
69rem for i
70
71
72
73:finished
74
75Endlocal & SET PYTHON_DIR=%PYTHON_DIR% & SET PYTHON=%PYTHON%
76
77if "%PYTHON_DIR%" == "" (
78rem @echo No Python dir
79set PYTHON=python
80goto running
81)
82
83rem @echo %PYTHON_DIR%
84
85if "%PYTHON%" == "" (
86rem @echo No Python
87set PYTHON=python
88goto running
89)
90
91:running
92
93@echo Using %PYTHON%
94
95"%PYTHON%" -x "%~dp0waf" %* & Endlocal & exit /b %ERRORLEVEL%
96