parameters: (compiler: str)
return_statement: return False
docstring: r'''
      Verifies that the compiler is the expected one for the current platform.
  
      Args:
          compiler (str): The compiler executable to check.
  
      Returns:
          True if the compiler is gcc/g++ on Linux or clang/clang++ on macOS,
          and always True for Windows.
docstring_summary: r'''
      Verifies that the compiler is the expected one for the current platform.
docstring_tokens: r Verifies that the compiler is the expected one for the current platform .
function: def check_compiler_ok_for_platform(compiler: str) -> bool:
      r'''
      Verifies that the compiler is the expected one for the current platform.
  
      Args:
          compiler (str): The compiler executable to check.
  
      Returns:
          True if the compiler is gcc/g++ on Linux or clang/clang++ on macOS,
          and always True for Windows.
      '''
      if IS_WINDOWS:
          return True
      which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT)
      # 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())
      # Check the compiler name
      if any(name in compiler_path for name in _accepted_compilers_for_platform()):
          return True
      # If compiler wrapper is used try to infer the actual compiler by invoking it with -v flag
      version_string = subprocess.check_output([compiler, '-v'], stderr=subprocess.STDOUT).decode(*SUBPROCESS_DECODE_ARGS)
      if IS_LINUX:
          # Check for 'gcc' or 'g++' for sccache warpper
          pattern = re.compile("^COLLECT_GCC=(.*)$", re.MULTILINE)
          results = re.findall(pattern, version_string)
          if len(results) != 1:
              return False
          compiler_path = os.path.realpath(results[0].strip())
          # On RHEL/CentOS c++ is a gcc compiler wrapper
          if os.path.basename(compiler_path) == 'c++' and 'gcc version' in version_string:
              return True
          return any(name in compiler_path for name in _accepted_compilers_for_platform())
      if IS_MACOS:
          # Check for 'clang' or 'clang++'
          return version_string.startswith("Apple clang")
      return False
function_tokens: def check_compiler_ok_for_platform ( compiler : str ) -> bool : if IS_WINDOWS : return True which = subprocess . check_output ( [ 'which' , compiler ] , stderr = subprocess . STDOUT ) # 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 ( ) ) # Check the compiler name if any ( name in compiler_path for name in _accepted_compilers_for_platform ( ) ) : return True # If compiler wrapper is used try to infer the actual compiler by invoking it with -v flag version_string = subprocess . check_output ( [ compiler , '-v' ] , stderr = subprocess . STDOUT ) . decode ( * SUBPROCESS_DECODE_ARGS ) if IS_LINUX : # Check for 'gcc' or 'g++' for sccache warpper pattern = re . compile ( "^COLLECT_GCC=(.*)$" , re . MULTILINE ) results = re . findall ( pattern , version_string ) if len ( results ) != 1 : return False compiler_path = os . path . realpath ( results [ 0 ] . strip ( ) ) # On RHEL/CentOS c++ is a gcc compiler wrapper if os . path . basename ( compiler_path ) == 'c++' and 'gcc version' in version_string : return True return any ( name in compiler_path for name in _accepted_compilers_for_platform ( ) ) if IS_MACOS : # Check for 'clang' or 'clang++' return version_string . startswith ( "Apple clang" ) return False