@@ -226,6 +226,8 @@ def build_cmake(self, extension):
226226 if sys .platform == "win32" :
227227 cuda_path = os .environ .get ("CUDA_PATH" )
228228 cmake_args += [f'-T cuda={ cuda_path } ' ]
229+ # TODO: temporarily add a flag for MSVC 19.40
230+ cmake_args += ['-DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler' ]
229231 f_ver = ext_fullpath .parent / "_version.py"
230232 with f_ver .open ('a' ) as _f :
231233 _f .writelines (["\n " , f"cuda = \" { cuda_ver } \" " , "\n " ])
@@ -235,7 +237,8 @@ def build_cmake(self, extension):
235237 else :
236238 smi = _load_nvidia_smi ()
237239 if not smi :
238- raise RuntimeError (f"Cannot detect the CUDA archs from your machine, please specify it by yourself." )
240+ raise RuntimeError (
241+ "Cannot detect the CUDA archs from your machine, please specify it manually." )
239242 cmake_args += ['-DCMAKE_CUDA_ARCHITECTURES=' + smi ]
240243
241244 # CMake lets you override the generator - we need to check this.
@@ -274,7 +277,6 @@ def build_cmake(self, extension):
274277 cmake_args += [
275278 "-DCMAKE_OSX_ARCHITECTURES={}" .format (";" .join (archs ))]
276279
277-
278280 # overwrite the Python module info if the auto-detection doesn't work.
279281 # export Python3_INCLUDE_DIRS=/opt/python/cp38-cp38
280282 # export Python3_LIBRARIES=/opt/python/cp38-cp38
@@ -292,14 +294,18 @@ def build_cmake(self, extension):
292294 '--parallel' + ('' if cpu_number is None else ' ' + cpu_number )
293295 ]
294296 cmake_exe = 'cmake'
295- # unlike Linux/macOS, cmake pip package on Windows fails to build some 3rd party dependencies.
296- # so we have to use the cmake installed from Visual Studio.
297- if os .environ .get (VSINSTALLDIR_NAME ):
298- cmake_exe = os .environ [VSINSTALLDIR_NAME ] + \
299- 'Common7\\ IDE\\ CommonExtensions\\ Microsoft\\ CMake\\ CMake\\ bin\\ cmake.exe'
300- # Add this cmake directory into PATH to make sure the child-process still find it.
301- os .environ ['PATH' ] = os .path .dirname (
302- cmake_exe ) + os .pathsep + os .environ ['PATH' ]
297+ # if sys.platform == "win32":
298+ # # unlike Linux/macOS, cmake pip package on Windows fails to build some 3rd party dependencies.
299+ # # so we have to use the cmake from a standalone installation or the one from Visual Studio.
300+ # standalone_cmake = os.path.join(os.environ.get("ProgramFiles"), "\\CMake\\bin\\cmake.exe")
301+ # if os.path.exists(standalone_cmake):
302+ # cmake_exe = standalone_cmake
303+ # elif os.environ.get(VSINSTALLDIR_NAME):
304+ # cmake_exe = os.environ[VSINSTALLDIR_NAME] + \
305+ # 'Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe'
306+ # # Add this cmake directory into PATH to make sure the child-process still find it.
307+ # os.environ['PATH'] = os.path.dirname(
308+ # cmake_exe) + os.pathsep + os.environ['PATH']
303309
304310 self .spawn ([cmake_exe , '-S' , str (project_dir ),
305311 '-B' , str (build_temp )] + cmake_args )
0 commit comments