@@ -79,32 +79,40 @@ def _find_vc2017():
79
79
if not root :
80
80
return None , None
81
81
82
- try :
83
- path = subprocess .check_output (
84
- [
85
- os .path .join (
86
- root , "Microsoft Visual Studio" , "Installer" , "vswhere.exe"
87
- ),
88
- "-latest" ,
89
- "-prerelease" ,
90
- "-requires" ,
91
- "Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ,
92
- "-property" ,
93
- "installationPath" ,
94
- "-products" ,
95
- "*" ,
96
- ],
97
- encoding = "mbcs" ,
98
- errors = "strict" ,
99
- ).strip ()
100
- except (subprocess .CalledProcessError , OSError , UnicodeDecodeError ):
101
- return None , None
82
+ variant = 'arm64' if get_platform () == 'win-arm64' else 'x86.x64'
83
+ suitable_components = (
84
+ f"Microsoft.VisualStudio.Component.VC.Tools.{ variant } " ,
85
+ "Microsoft.VisualStudio.Workload.WDExpress" ,
86
+ )
87
+
88
+ for component in suitable_components :
89
+ # Workaround for `-requiresAny` (only available on VS 2017 > 15.6)
90
+ with contextlib .suppress (
91
+ subprocess .CalledProcessError , OSError , UnicodeDecodeError
92
+ ):
93
+ path = (
94
+ subprocess .check_output ([
95
+ os .path .join (
96
+ root , "Microsoft Visual Studio" , "Installer" , "vswhere.exe"
97
+ ),
98
+ "-latest" ,
99
+ "-prerelease" ,
100
+ "-requires" ,
101
+ component ,
102
+ "-property" ,
103
+ "installationPath" ,
104
+ "-products" ,
105
+ "*" ,
106
+ ])
107
+ .decode (encoding = "mbcs" , errors = "strict" )
108
+ .strip ()
109
+ )
102
110
103
- path = os .path .join (path , "VC" , "Auxiliary" , "Build" )
104
- if os .path .isdir (path ):
105
- return 15 , path
111
+ path = os .path .join (path , "VC" , "Auxiliary" , "Build" )
112
+ if os .path .isdir (path ):
113
+ return 15 , path
106
114
107
- return None , None
115
+ return None , None # no suitable component found
108
116
109
117
110
118
PLAT_SPEC_TO_RUNTIME = {
@@ -140,7 +148,11 @@ def _get_vc_env(plat_spec):
140
148
141
149
vcvarsall , _ = _find_vcvarsall (plat_spec )
142
150
if not vcvarsall :
143
- raise DistutilsPlatformError ("Unable to find vcvarsall.bat" )
151
+ raise DistutilsPlatformError (
152
+ 'Microsoft Visual C++ 14.0 or greater is required. '
153
+ 'Get it with "Microsoft C++ Build Tools": '
154
+ 'https://visualstudio.microsoft.com/visual-cpp-build-tools/'
155
+ )
144
156
145
157
try :
146
158
out = subprocess .check_output (
0 commit comments