File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
python/paddle/utils/cpp_extension Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -612,12 +612,34 @@ def find_paddle_includes(use_cuda=False):
612612
613613 if OS_NAME .startswith ('darwin' ):
614614 # NOTE(Aurelius84): Ensure to find std v1 headers correctly.
615- std_v1_includes = '/Library/Developer/CommandLineTools/usr/include/c++/v1/'
616- include_dirs .append (std_v1_includes )
615+ std_v1_includes = find_clang_cpp_include ()
616+ if std_v1_includes is not None and os .path .exists (std_v1_includes ):
617+ include_dirs .append (std_v1_includes )
617618
618619 return include_dirs
619620
620621
622+ def find_clang_cpp_include (compiler = 'clang' ):
623+ std_v1_includes = None
624+ try :
625+ compiler_version = subprocess .check_output ([compiler , "--version" ])
626+ if six .PY3 :
627+ compiler_version = compiler_version .decode ()
628+ infos = compiler_version .split ("\n " )
629+ for info in infos :
630+ if "InstalledDir" in info :
631+ v1_path = info .split (':' )[- 1 ].strip ()
632+ if v1_path and os .path .exists (v1_path ):
633+ std_v1_includes = os .path .join (
634+ os .path .dirname (v1_path ), 'include/c++/v1' )
635+ except Exception :
636+ # Just raise warnings because the include dir is not required.
637+ warnings .warn (
638+ "Failed to search `include/c++/v1/` include dirs. Don't worry because it's not required."
639+ )
640+ return std_v1_includes
641+
642+
621643def find_cuda_libraries ():
622644 """
623645 Use heuristic method to find cuda static lib path
You can’t perform that action at this time.
0 commit comments