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