@@ -103,56 +103,6 @@ def copy_externals():
103103 ]
104104
105105
106- def find_vswhere ():
107- program_files = os .environ .get ("ProgramFiles(x86)" , "C:\\ Program Files (x86)" )
108- vswhere_path = Path (program_files ) / "Microsoft Visual Studio" / "Installer" / "vswhere.exe"
109- if vswhere_path .exists ():
110- return vswhere_path
111- return None
112-
113-
114- def find_visual_studio (version_ranges ):
115- vswhere = find_vswhere ()
116- if not vswhere :
117- raise FileNotFoundError ("vswhere.exe not found." )
118-
119- for version_range in version_ranges :
120- command = [
121- str (vswhere ), "-version" , version_range , "-requires" , "Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ,
122- "-products" , "*" , "-property" , "installationPath" , "-prerelease"
123- ]
124-
125- try :
126- output = subprocess .check_output (command , text = True ).strip ()
127- if output :
128- return output .split ("\n " )[0 ]
129- except subprocess .CalledProcessError :
130- continue
131-
132- return None
133-
134-
135- def set_env_vars (vs_path , arch = "x64" ):
136- vcvarsall_path = Path (vs_path ) / "VC" / "Auxiliary" / "Build" / "vcvarsall.bat"
137- if not vcvarsall_path .exists ():
138- raise FileNotFoundError (f"vcvarsall.bat not found in expected path: { vcvarsall_path } " )
139-
140- command = ["call" , vcvarsall_path , arch , "&&" , "set" ]
141- output = subprocess .check_output (command , shell = True , text = True )
142-
143- for line in output .splitlines ():
144- if '=' in line :
145- var , value = line .split ('=' , 1 )
146- os .environ [var ] = value
147-
148-
149- def initialize_visual_studio_env (version_ranges , arch = "x64" ):
150- vs_path = find_visual_studio (version_ranges )
151- if not vs_path :
152- raise EnvironmentError ("Visual Studio not found in specified version ranges." )
153- set_env_vars (vs_path , arch )
154-
155-
156106# Taken from https://github.com/pytorch/pytorch/blob/master/tools/setup_helpers/env.py
157107def check_env_flag (name : str , default : str = "" ) -> bool :
158108 return os .getenv (name , default ).upper () in ["ON" , "1" , "YES" , "TRUE" , "Y" ]
@@ -475,8 +425,6 @@ def get_proton_cmake_args(self):
475425 def build_extension (self , ext ):
476426 lit_dir = shutil .which ('lit' )
477427 ninja_dir = shutil .which ('ninja' )
478- if platform .system () == "Windows" :
479- initialize_visual_studio_env (["[17.0,18.0)" , "[16.0,17.0)" ])
480428 # lit is used by the test suite
481429 thirdparty_cmake_args = get_thirdparty_packages ([get_llvm_package_info ()])
482430 thirdparty_cmake_args += self .get_pybind11_cmake_args ()
0 commit comments