Skip to content

Commit 57d52c0

Browse files
committed
Updated appveyor environment configuration batch file to compile correctly for Python versions 3.x (64bit).
1 parent 0c3bdfa commit 57d52c0

File tree

1 file changed

+56
-17
lines changed

1 file changed

+56
-17
lines changed

appveyor/run_with_env.cmd

+56-17
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
77
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
88
::
9-
:: 32 bit builds do not require specific environment configurations.
9+
:: 32 bit builds, and 64-bit builds for 3.5 and beyond, do not require specific
10+
:: environment configurations.
1011
::
1112
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
1213
:: cmd interpreter, at least for (SDK v7.0)
@@ -17,31 +18,69 @@
1718
::
1819
:: Author: Olivier Grisel
1920
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
21+
::
22+
:: Notes about batch files for Python people:
23+
::
24+
:: Quotes in values are literally part of the values:
25+
:: SET FOO="bar"
26+
:: FOO is now five characters long: " b a r "
27+
:: If you don't want quotes, don't include them on the right-hand side.
28+
::
29+
:: The CALL lines at the end of this file look redundant, but if you move them
30+
:: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y
31+
:: case, I don't know why.
2032
@ECHO OFF
2133

2234
SET COMMAND_TO_RUN=%*
2335
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
36+
SET WIN_WDK=c:\Program Files (x86)\Windows Kits\10\Include\wdf
2437

25-
SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
26-
IF %MAJOR_PYTHON_VERSION% == "2" (
38+
:: Extract the major and minor versions, and allow for the minor version to be
39+
:: more than 9. This requires the version number to have two dots in it.
40+
SET MAJOR_PYTHON_VERSION=%PYTHON_VERSION:~0,1%
41+
IF "%PYTHON_VERSION:~3,1%" == "." (
42+
SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1%
43+
) ELSE (
44+
SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,2%
45+
)
46+
:: Based on the Python version, determine what SDK version to use, and whether
47+
:: to set the SDK for 64-bit.
48+
IF %MAJOR_PYTHON_VERSION% == 2 (
2749
SET WINDOWS_SDK_VERSION="v7.0"
28-
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
29-
SET WINDOWS_SDK_VERSION="v7.1"
50+
SET SET_SDK_64=Y
3051
) ELSE (
31-
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
32-
EXIT 1
52+
IF %MAJOR_PYTHON_VERSION% == 3 (
53+
SET WINDOWS_SDK_VERSION="v7.1"
54+
IF %MINOR_PYTHON_VERSION% LEQ 4 (
55+
SET SET_SDK_64=Y
56+
) ELSE (
57+
SET SET_SDK_64=N
58+
IF EXIST "%WIN_WDK%" (
59+
:: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/
60+
REN "%WIN_WDK%" 0wdf
61+
)
62+
)
63+
) ELSE (
64+
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
65+
EXIT 1
66+
)
3367
)
34-
35-
IF "%PYTHON_ARCH%"=="64" (
36-
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
37-
SET DISTUTILS_USE_SDK=1
38-
SET MSSdk=1
39-
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
40-
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
41-
ECHO Executing: %COMMAND_TO_RUN%
42-
call %COMMAND_TO_RUN% || EXIT 1
68+
IF %PYTHON_ARCH% == 64 (
69+
IF %SET_SDK_64% == Y (
70+
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
71+
SET DISTUTILS_USE_SDK=1
72+
SET MSSdk=1
73+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
74+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
75+
ECHO Executing: %COMMAND_TO_RUN%
76+
call %COMMAND_TO_RUN% || EXIT 1
77+
) ELSE (
78+
ECHO Using default MSVC build environment for 64 bit architecture
79+
ECHO Executing: %COMMAND_TO_RUN%
80+
call %COMMAND_TO_RUN% || EXIT 1
81+
)
4382
) ELSE (
4483
ECHO Using default MSVC build environment for 32 bit architecture
4584
ECHO Executing: %COMMAND_TO_RUN%
4685
call %COMMAND_TO_RUN% || EXIT 1
47-
)
86+
)

0 commit comments

Comments
 (0)