Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Use 141 toolchain for Windows build #146

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- template: azure/windows.yml
parameters:
name: "windows2019"
vmImage: "windows-latest"
vmImage: "windows-2019"
timeoutInMinutes: 90
matrix:
py_3.8_32:
Expand Down
71 changes: 71 additions & 0 deletions azure/set_vs_toolchain.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@@echo on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add something like

REM Taken from conda-forge recipes licensed as follows
REM BSD-3-Clause
REM Copyright conda-forge contributors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - see: #150

REM set Visual Studio toolchain given bitness, VS year and toolchain number.
IF [%1] == [] GOTO NoArgErr
set VS_BITS=%1
IF [%2] == [] GOTO NoArgErr
set VS_YEAR=%2
IF [%3] == [] GOTO NoArgErr
set VS_TOOLCHAIN=%3


REM Tools can come from any of Professional, Community, BuildTools or Enterprise install.
if not exist "%VSINSTALLDIR%" (
set "VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_YEAR%\Professional\"
)
if not exist "%VSINSTALLDIR%" (
set "VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_YEAR%\Community\"
)
if not exist "%VSINSTALLDIR%" (
set "VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_YEAR%\BuildTools\"
)
if not exist "%VSINSTALLDIR%" (
set "VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_YEAR%\Enterprise\"
)

REM Discover the latest Windows SDK available.
call :GetWin10SdkDir
:: dir /ON here is sorting the list of folders, such that we use the latest one that we have
for /F %%i in ('dir /ON /B "%WindowsSdkDir%\include\10.*"') DO (
SET WindowsSDKVer=%%~i
)
if errorlevel 1 (
echo "Didn't find any windows 10 SDK. I'm not sure if things will work, but let's try..."
) else (
echo Windows SDK version found as: "%WindowsSDKVer%"
)

REM Set bitness, toolchain version and SDK.
call "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvars%1.bat" -vcvars_ver=%VS_TOOLCHAIN% %WindowsSDKVer%
REM https://docs.python.org/3.9/distutils/apiref.html#module-distutils.msvccompiler
REM or
REM https://setuptools.pypa.io/en/latest/deprecated/distutils/apiref.html#module-distutils.msvccompiler
REM Force our SDK, rather than the Python was built with.
set DISTUTILS_USE_SDK=1
set MSSdk=1

REM All done, finish here.
goto:eof

REM Various subroutines.

:GetWin10SdkDir
call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node > nul 2>&1
if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node > nul 2>&1
if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE > nul 2>&1
if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE > nul 2>&1
if errorlevel 1 exit /B 1
exit /B 0

:GetWin10SdkDirHelper
@@REM `Get Windows 10 SDK installed folder`
for /F "tokens=1,2*" %%i in ('reg query "%1\Microsoft\Microsoft SDKs\Windows\v10.0" /v "InstallationFolder"') DO (
if "%%i"=="InstallationFolder" (
SET WindowsSdkDir=%%~k
)
)
exit /B 0

:NoArgErr
echo "Need to specify input bitness, VS year and toolchain number"
echo "e.g 64 2019 14.16"
exit 1
9 changes: 9 additions & 0 deletions azure/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ jobs:
- checkout: self
submodules: true

- task: BatchScript@1
inputs:
filename: azure/set_vs_toolchain.cmd
arguments: $(BITS) 2019 14.16
modifyEnvironment: True
displayName: Set VS toolchain version

- task: UsePythonVersion@0
inputs:
versionSpec: $(PYTHON_VERSION)
Expand Down Expand Up @@ -122,6 +129,8 @@ jobs:
popd
displayName: Build wheel
- bash: |
# Undo use specify VS build tools.
unset DISTUTILS_USE_SDK MSSdk
set -ex
source extra_functions.sh
source config.sh
Expand Down