mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
use shutil.which in check_compiler_ok_for_platform (#129069)
the same as https://github.com/pytorch/pytorch/pull/126060 Pull Request resolved: https://github.com/pytorch/pytorch/pull/129069 Approved by: https://github.com/ezyang
This commit is contained in:
@ -308,9 +308,11 @@ def check_compiler_ok_for_platform(compiler: str) -> bool:
|
||||
"""
|
||||
if IS_WINDOWS:
|
||||
return True
|
||||
which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT)
|
||||
compiler_path = shutil.which(compiler)
|
||||
if compiler_path is None:
|
||||
return False
|
||||
# Use os.path.realpath to resolve any symlinks, in particular from 'c++' to e.g. 'g++'.
|
||||
compiler_path = os.path.realpath(which.decode(*SUBPROCESS_DECODE_ARGS).strip())
|
||||
compiler_path = os.path.realpath(compiler_path)
|
||||
# Check the compiler name
|
||||
if any(name in compiler_path for name in _accepted_compilers_for_platform()):
|
||||
return True
|
||||
|
Reference in New Issue
Block a user