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

Commit 22584fe

Browse files
Use 141 toolchain for Windows build (#146)
* Use defined image windows-2019 latest image seems like a hostage to fortune. * Add, use script to set VS toolchain version * Unset Distutils SDK stuff before tests
1 parent eeafa52 commit 22584fe

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- template: azure/windows.yml
1818
parameters:
1919
name: "windows2019"
20-
vmImage: "windows-latest"
20+
vmImage: "windows-2019"
2121
timeoutInMinutes: 90
2222
matrix:
2323
py_3.8_32:

azure/set_vs_toolchain.cmd

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@@echo on
2+
REM set Visual Studio toolchain given bitness, VS year and toolchain number.
3+
IF [%1] == [] GOTO NoArgErr
4+
set VS_BITS=%1
5+
IF [%2] == [] GOTO NoArgErr
6+
set VS_YEAR=%2
7+
IF [%3] == [] GOTO NoArgErr
8+
set VS_TOOLCHAIN=%3
9+
10+
11+
REM Tools can come from any of Professional, Community, BuildTools or Enterprise install.
12+
if not exist "%VSINSTALLDIR%" (
13+
set "VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_YEAR%\Professional\"
14+
)
15+
if not exist "%VSINSTALLDIR%" (
16+
set "VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_YEAR%\Community\"
17+
)
18+
if not exist "%VSINSTALLDIR%" (
19+
set "VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_YEAR%\BuildTools\"
20+
)
21+
if not exist "%VSINSTALLDIR%" (
22+
set "VSINSTALLDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_YEAR%\Enterprise\"
23+
)
24+
25+
REM Discover the latest Windows SDK available.
26+
call :GetWin10SdkDir
27+
:: dir /ON here is sorting the list of folders, such that we use the latest one that we have
28+
for /F %%i in ('dir /ON /B "%WindowsSdkDir%\include\10.*"') DO (
29+
SET WindowsSDKVer=%%~i
30+
)
31+
if errorlevel 1 (
32+
echo "Didn't find any windows 10 SDK. I'm not sure if things will work, but let's try..."
33+
) else (
34+
echo Windows SDK version found as: "%WindowsSDKVer%"
35+
)
36+
37+
REM Set bitness, toolchain version and SDK.
38+
call "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvars%1.bat" -vcvars_ver=%VS_TOOLCHAIN% %WindowsSDKVer%
39+
REM https://docs.python.org/3.9/distutils/apiref.html#module-distutils.msvccompiler
40+
REM or
41+
REM https://setuptools.pypa.io/en/latest/deprecated/distutils/apiref.html#module-distutils.msvccompiler
42+
REM Force our SDK, rather than the Python was built with.
43+
set DISTUTILS_USE_SDK=1
44+
set MSSdk=1
45+
46+
REM All done, finish here.
47+
goto:eof
48+
49+
REM Various subroutines.
50+
51+
:GetWin10SdkDir
52+
call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node > nul 2>&1
53+
if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node > nul 2>&1
54+
if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE > nul 2>&1
55+
if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE > nul 2>&1
56+
if errorlevel 1 exit /B 1
57+
exit /B 0
58+
59+
:GetWin10SdkDirHelper
60+
@@REM `Get Windows 10 SDK installed folder`
61+
for /F "tokens=1,2*" %%i in ('reg query "%1\Microsoft\Microsoft SDKs\Windows\v10.0" /v "InstallationFolder"') DO (
62+
if "%%i"=="InstallationFolder" (
63+
SET WindowsSdkDir=%%~k
64+
)
65+
)
66+
exit /B 0
67+
68+
:NoArgErr
69+
echo "Need to specify input bitness, VS year and toolchain number"
70+
echo "e.g 64 2019 14.16"
71+
exit 1

azure/windows.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ jobs:
2020
- checkout: self
2121
submodules: true
2222

23+
- task: BatchScript@1
24+
inputs:
25+
filename: azure/set_vs_toolchain.cmd
26+
arguments: $(BITS) 2019 14.16
27+
modifyEnvironment: True
28+
displayName: Set VS toolchain version
29+
2330
- task: UsePythonVersion@0
2431
inputs:
2532
versionSpec: $(PYTHON_VERSION)
@@ -122,6 +129,8 @@ jobs:
122129
popd
123130
displayName: Build wheel
124131
- bash: |
132+
# Undo use specify VS build tools.
133+
unset DISTUTILS_USE_SDK MSSdk
125134
set -ex
126135
source extra_functions.sh
127136
source config.sh

0 commit comments

Comments
 (0)