Alexander Afanasyev | e334215 | 2016-03-20 11:23:57 -0700 | [diff] [blame^] | 1 | @echo off
|
| 2 |
|
| 3 | rem from issue #964
|
| 4 |
|
| 5 | Setlocal EnableDelayedExpansion
|
| 6 |
|
| 7 | rem Check Windows Version
|
| 8 | set TOKEN=tokens=3*
|
| 9 | ver | findstr /i "5\.0\." > nul
|
| 10 | if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
|
| 11 | ver | findstr /i "5\.1\." > nul
|
| 12 | if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
|
| 13 | ver | findstr /i "5\.2\." > nul
|
| 14 | if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
|
| 15 | ver | findstr /i "6\.0\." > nul
|
| 16 | if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=2*
|
| 17 | ver | findstr /i "6\.1\." > nul
|
| 18 | if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=2*
|
| 19 |
|
| 20 | rem Start calculating PYTHON and PYTHON_DIR
|
| 21 | set PYTHON=
|
| 22 | set PYTHON_DIR=
|
| 23 |
|
| 24 | Setlocal EnableDelayedExpansion
|
| 25 |
|
| 26 | set PYTHON_DIR_OK=FALSE
|
| 27 | set REGPATH=
|
| 28 |
|
| 29 | for %%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 (
|
| 30 | for %%j in (HKCU HKLM) do (
|
| 31 | for %%k in (SOFTWARE\Wow6432Node SOFTWARE) do (
|
| 32 | for %%l in (Python\PythonCore IronPython) do (
|
| 33 | set REG_PYTHON_EXE=python.exe
|
| 34 | if "%%l"=="IronPython" (
|
| 35 | set REG_PYTHON_EXE=ipy.exe
|
| 36 | )
|
| 37 |
|
| 38 | @echo on
|
| 39 |
|
| 40 | set REGPATH=%%j\%%k\%%l\%%i\InstallPath
|
| 41 | rem @echo Regpath !REGPATH!
|
| 42 | REG QUERY "!REGPATH!" /ve 1>nul 2>nul
|
| 43 | if !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 |
|
| 60 | echo off
|
| 61 |
|
| 62 | )
|
| 63 | rem for l
|
| 64 | )
|
| 65 | rem for k
|
| 66 | )
|
| 67 | rem for j
|
| 68 | )
|
| 69 | rem for i
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 | :finished
|
| 74 |
|
| 75 | Endlocal & SET PYTHON_DIR=%PYTHON_DIR% & SET PYTHON=%PYTHON%
|
| 76 |
|
| 77 | if "%PYTHON_DIR%" == "" (
|
| 78 | rem @echo No Python dir
|
| 79 | set PYTHON=python
|
| 80 | goto running
|
| 81 | )
|
| 82 |
|
| 83 | rem @echo %PYTHON_DIR%
|
| 84 |
|
| 85 | if "%PYTHON%" == "" (
|
| 86 | rem @echo No Python
|
| 87 | set PYTHON=python
|
| 88 | goto running
|
| 89 | )
|
| 90 |
|
| 91 | :running
|
| 92 |
|
| 93 | @echo Using %PYTHON%
|
| 94 |
|
| 95 | "%PYTHON%" -x "%~dp0waf" %* & Endlocal & exit /b %ERRORLEVEL%
|
| 96 |
|