@@ -159,27 +159,28 @@ def _find_rocm_home() -> Optional[str]:
159159 # Guess #1
160160 rocm_home = os .environ .get ("ROCM_HOME" ) or os .environ .get ("ROCM_PATH" )
161161 if rocm_home is None :
162- # Guess #2: rocm-sdk-devel pip package ships a self-contained ROCm
163- # tree under site-packages/_rocm_sdk_devel/. Prefer this over a
164- # hipcc-on-PATH lookup because the venv's bin/hipcc is a python
165- # wrapper, not a real binary — realpath() can't recover the SDK
166- # root from it.
167- try :
168- spec = importlib .util .find_spec ("_rocm_sdk_devel" )
169- except (ImportError , ValueError ):
170- spec = None
171- if spec is not None and spec .submodule_search_locations :
162+ # Guess #2: TheRock split wheels install the runtime/toolchain under
163+ # _rocm_sdk_core, while older layouts may expose a self-contained tree
164+ # through _rocm_sdk_devel. Prefer the core runtime when both exist.
165+ # This must precede PATH lookup because wheel-provided hipcc is not
166+ # necessarily added to PATH.
167+ for package_name in ("_rocm_sdk_core" , "_rocm_sdk_devel" ):
168+ try :
169+ spec = importlib .util .find_spec (package_name )
170+ except (ImportError , ValueError ):
171+ spec = None
172+ if spec is None or not spec .submodule_search_locations :
173+ continue
172174 candidate = spec .submodule_search_locations [0 ]
173175 hipconfig_names = (
174- ("hipconfig.exe" , "hipconfig" )
175- if IS_WINDOWS
176- else ("hipconfig" ,)
176+ ("hipconfig.exe" , "hipconfig" ) if IS_WINDOWS else ("hipconfig" ,)
177177 )
178178 if any (
179179 os .path .exists (os .path .join (candidate , "bin" , name ))
180180 for name in hipconfig_names
181181 ) and os .path .exists (os .path .join (candidate , "lib" )):
182182 rocm_home = candidate
183+ break
183184 if rocm_home is None :
184185 # Guess #3
185186 hipcc_path = shutil .which ("hipcc" )
@@ -406,6 +407,9 @@ def check_compiler_ok_for_platform(compiler: str) -> bool:
406407 True if the compiler is gcc/g++ on Linux or clang/clang++ on macOS,
407408 and always True for Windows.
408409 """
410+ if IS_WINDOWS :
411+ return True
412+
409413 found_compiler = shutil .which (compiler )
410414 if not found_compiler :
411415 return False
@@ -479,26 +483,34 @@ def get_compiler_abi_compatibility_and_version(
479483 try :
480484 if IS_LINUX :
481485 minimum_required_version = MINIMUM_GCC_VERSION
482- versionstr = subprocess .check_output (
486+ compiler_info = subprocess .check_output (
483487 [compiler , "-dumpfullversion" , "-dumpversion" ]
484488 )
485- match = re .search (
486- r"(\d+)\.(\d+)\.(\d+)" ,
487- versionstr .decode (* SUBPROCESS_DECODE_ARGS ).strip (),
489+ elif IS_WINDOWS :
490+ minimum_required_version = MINIMUM_MSVC_VERSION
491+ compiler_info = subprocess .check_output (
492+ compiler , stderr = subprocess .STDOUT
488493 )
489- version = ["0" , "0" , "0" ] if match is None else list (match .groups ())
494+ else :
495+ return (True , Version ("0.0.0" ))
496+ match = re .search (
497+ r"(\d+)\.(\d+)\.(\d+)" ,
498+ compiler_info .decode (* SUBPROCESS_DECODE_ARGS ).strip (),
499+ )
500+ version = ["0" , "0" , "0" ] if match is None else list (match .groups ())
490501 except Exception :
491502 _ , error , _ = sys .exc_info ()
492503 warnings .warn (f"Error checking compiler version for { compiler } : { error } " )
493504 return (False , Version ("0.0.0" ))
494505
495- if tuple (map (int , version )) >= minimum_required_version :
496- return (True , Version ("." .join (version )))
506+ numeric_version = [re .sub (r"\D" , "" , component ) for component in version ]
507+ if tuple (map (int , numeric_version )) >= minimum_required_version :
508+ return (True , Version ("." .join (numeric_version )))
497509
498- compiler = f'{ compiler } { "." .join (version )} '
510+ compiler = f'{ compiler } { "." .join (numeric_version )} '
499511 warnings .warn (ABI_INCOMPATIBILITY_WARNING .format (compiler ))
500512
501- return (False , Version ("." .join (version )))
513+ return (False , Version ("." .join (numeric_version )))
502514
503515
504516class BuildExtension (build_ext ):
@@ -1781,9 +1793,9 @@ def _write_ninja_file_to_build_library(
17811793 + COMMON_HIP_FLAGS
17821794 + COMMON_HIPCC_FLAGS
17831795 + ["-std=c++20" ]
1796+ + extra_cuda_cflags
17841797 )
17851798 cuda_flags += _get_rocm_arch_flags (cuda_flags )
1786- cuda_flags += extra_cuda_cflags
17871799 if IS_WINDOWS :
17881800 cuda_flags = _nt_quote_args (cuda_flags )
17891801
0 commit comments