run_with_compiler.cmd 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. :: To build extensions for 64 bit Python 3, we need to configure environment
  2. :: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
  3. :: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
  4. ::
  5. :: To build extensions for 64 bit Python 2, we need to configure environment
  6. :: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
  7. :: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
  8. ::
  9. :: 32 bit builds do not require specific environment configurations.
  10. ::
  11. :: Note: this script needs to be run with the /E:ON and /V:ON flags for the
  12. :: cmd interpreter, at least for (SDK v7.0)
  13. ::
  14. :: More details at:
  15. :: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
  16. :: https://stackoverflow.com/a/13751649/163740
  17. ::
  18. :: Author: Olivier Grisel
  19. :: License: CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/
  20. @ECHO OFF
  21. SET COMMAND_TO_RUN=%*
  22. SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
  23. SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
  24. IF %MAJOR_PYTHON_VERSION% == "2" (
  25. SET WINDOWS_SDK_VERSION="v7.0"
  26. ) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
  27. SET WINDOWS_SDK_VERSION="v7.1"
  28. ) ELSE (
  29. ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
  30. EXIT 1
  31. )
  32. IF "%PYTHON_ARCH%"=="64" (
  33. ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
  34. SET DISTUTILS_USE_SDK=1
  35. SET MSSdk=1
  36. "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
  37. "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
  38. ECHO Executing: %COMMAND_TO_RUN%
  39. call %COMMAND_TO_RUN% || EXIT 1
  40. ) ELSE (
  41. ECHO Using default MSVC build environment for 32 bit architecture
  42. ECHO Executing: %COMMAND_TO_RUN%
  43. call %COMMAND_TO_RUN% || EXIT 1
  44. )