@@ -174,7 +174,7 @@ def determine_generator_args(cmake_version=None, windows_sdk_version=None):
174174 # This technique may not work with customized VS install paths.
175175 # An alternative would be to utilize private python calls:
176176 # (distutils._msvccompiler._find_vc2017() and _find_vc2015()).
177- if '\\ Microsoft Visual Studio\\ 2026 ' in compiler .cc :
177+ if '\\ Microsoft Visual Studio\\ 18 ' in compiler .cc :
178178 vs_version = 18
179179 vs_year = 2026
180180 elif '\\ Microsoft Visual Studio\\ 2022' in compiler .cc :
@@ -189,23 +189,6 @@ def determine_generator_args(cmake_version=None, windows_sdk_version=None):
189189 elif '\\ Microsoft Visual Studio 14.0' in compiler .cc :
190190 vs_version = 14
191191 vs_year = 2015
192- else :
193- # Fallback: use vswhere.exe when distutils can't detect the VS version
194- # (e.g. Python 3.8 distutils doesn't know about VS2026)
195- import subprocess
196- vswhere = os .path .join (
197- os .environ .get ('ProgramFiles(x86)' , r'C:\Program Files (x86)' ),
198- 'Microsoft Visual Studio' , 'Installer' , 'vswhere.exe' )
199- if os .path .exists (vswhere ):
200- result = subprocess .run (
201- [vswhere , '-latest' , '-property' , 'installationVersion' ],
202- capture_output = True , text = True )
203- if result .returncode == 0 and result .stdout .strip ():
204- major = int (result .stdout .strip ().split ('.' )[0 ])
205- # VS major version -> marketing year mapping
206- major_to_year = {14 : 2015 , 15 : 2017 , 16 : 2019 , 17 : 2022 , 18 : 2026 }
207- vs_version = major
208- vs_year = major_to_year .get (major , 2022 + (major - 17 ) * 3 )
209192 assert (vs_version and vs_year )
210193 except Exception :
211194 raise RuntimeError ('No supported version of MSVC compiler could be found!' )
0 commit comments