1:: Author:  Lisandro Dalcin
2:: Contact: dalcinl@gmail.com
3:: Credits: Olivier Grisel and Kyle Kastner
4@ECHO OFF
5
6SET COMMAND_TO_RUN=%*
7
8SET PYTHON_VERSION_MAJOR=%PYTHON_VERSION:~0,1%
9SET PYTHON_VERSION_MINOR=%PYTHON_VERSION:~2,1%
10
11SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
12IF %PYTHON_VERSION_MAJOR% == 2 SET WIN_SDK_VERSION="v7.0"
13IF %PYTHON_VERSION_MAJOR% == 3 SET WIN_SDK_VERSION="v7.1"
14
15IF %PYTHON_ARCH% == 64 SET USE_WIN_SDK=1
16IF %PYTHON_VERSION_MAJOR% EQU 3 IF %PYTHON_VERSION_MINOR% GEQ 5 SET USE_WIN_SDK=0
17IF %PYTHON_VERSION_MAJOR% GTR 3 SET USE_WIN_SDK=0
18if %PYTHON_ARCH% == 32 SET USE_WIN_SDK=0
19
20IF %USE_WIN_SDK% == 1 (
21    ECHO Configuring Windows SDK %WIN_SDK_VERSION% for %PYTHON_ARCH% bit architecture
22    SET DISTUTILS_USE_SDK=1
23    SET MSSdk=1
24    "%WIN_SDK_ROOT%\%WIN_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WIN_SDK_VERSION%
25    "%WIN_SDK_ROOT%\%WIN_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
26    ECHO Executing: %COMMAND_TO_RUN%
27    CALL %COMMAND_TO_RUN% || EXIT 1
28) ELSE (
29    ECHO Using default MSVC build environment for %PYTHON_ARCH% bit architecture
30    ECHO Executing: %COMMAND_TO_RUN%
31    CALL %COMMAND_TO_RUN% || EXIT 1
32)
33