1:: From: https://github.com/ogrisel/python-appveyor-demo/blob/master/appveyor/run_with_env.cmd
2::
3::
4:: To build extensions for 64 bit Python 3, we need to configure environment
5:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
6:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
7::
8:: To build extensions for 64 bit Python 2, we need to configure environment
9:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
10:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
11::
12:: 32 bit builds, and 64-bit builds for 3.5 and beyond, do not require specific
13:: environment configurations.
14::
15:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
16:: cmd interpreter, at least for (SDK v7.0)
17::
18:: More details at:
19:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
20:: http://stackoverflow.com/a/13751649/163740
21::
22:: Author: Olivier Grisel
23:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
24::
25:: Notes about batch files for Python people:
26::
27:: Quotes in values are literally part of the values:
28::      SET FOO="bar"
29:: FOO is now five characters long: " b a r "
30:: If you don't want quotes, don't include them on the right-hand side.
31::
32:: The CALL lines at the end of this file look redundant, but if you move them
33:: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y
34:: case, I don't know why.
35@ECHO OFF
36
37SET COMMAND_TO_RUN=%*
38SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
39SET WIN_WDK=c:\Program Files (x86)\Windows Kits\10\Include\wdf
40
41:: Extract the major and minor versions, and allow for the minor version to be
42:: more than 9.  This requires the version number to have two dots in it.
43SET MAJOR_PYTHON_VERSION=%PYTHON_VERSION:~0,1%
44IF "%PYTHON_VERSION:~3,1%" == "." (
45    SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1%
46) ELSE (
47    SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,2%
48)
49
50:: Based on the Python version, determine what SDK version to use, and whether
51:: to set the SDK for 64-bit.
52IF %MAJOR_PYTHON_VERSION% == 2 (
53    SET WINDOWS_SDK_VERSION="v7.0"
54    SET SET_SDK_64=Y
55) ELSE (
56    IF %MAJOR_PYTHON_VERSION% == 3 (
57        SET WINDOWS_SDK_VERSION="v7.1"
58        IF %MINOR_PYTHON_VERSION% LEQ 4 (
59            SET SET_SDK_64=Y
60        ) ELSE (
61            SET SET_SDK_64=N
62            IF EXIST "%WIN_WDK%" (
63                :: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/
64                REN "%WIN_WDK%" 0wdf
65            )
66        )
67    ) ELSE (
68        ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
69        EXIT 1
70    )
71)
72
73IF %PYTHON_ARCH% == 64 (
74    IF %SET_SDK_64% == Y (
75        ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
76        SET DISTUTILS_USE_SDK=1
77        SET MSSdk=1
78        "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
79        "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
80        ECHO Executing: %COMMAND_TO_RUN%
81        call %COMMAND_TO_RUN% || EXIT 1
82    ) ELSE (
83        ECHO Using default MSVC build environment for 64 bit architecture
84        ECHO Executing: %COMMAND_TO_RUN%
85        call %COMMAND_TO_RUN% || EXIT 1
86    )
87) ELSE (
88    ECHO Using default MSVC build environment for 32 bit architecture
89    ECHO Executing: %COMMAND_TO_RUN%
90    call %COMMAND_TO_RUN% || EXIT 1
91)
92