code: def find_compiler(cls, preferred_vendor, metadir, cwd,
                        use_meta=True):
          
          cwd = cwd or '.'
          metadir = metadir or '.'
          metadir = os.path.join(cwd, metadir)
          used_metafile = False
          if not preferred_vendor and use_meta:
              try:
                  preferred_vendor = cls.get_from_metadata_file(
                      metadir, 'vendor')
                  used_metafile = True
              except FileNotFoundError:
                  pass
          candidates = list(cls.compiler_dict.keys())
          if preferred_vendor:
              if preferred_vendor in candidates:
                  candidates = [preferred_vendor]+candidates
              else:
                  raise ValueError("Unknown vendor {}".format(
                      preferred_vendor))
          name, path = find_binary_of_command([
              cls.compiler_dict[x] for x in candidates])
          if use_meta and not used_metafile:
              if not os.path.isdir(metadir):
                  raise FileNotFoundError("Not a dir: {}".format(metadir))
              cls.save_to_metadata_file(metadir, 'compiler',
                                        (name, path))
              cls.save_to_metadata_file(
                  metadir, 'vendor',
                  cls.compiler_name_vendor_mapping[name])
              if cls.logger:
                  cls.logger.info(
                      'Wrote choice of compiler to: metadir')
          return name, path, cls.compiler_name_vendor_mapping[name]
docs: Identify a suitable C/fortran/other compiler
  
          When it is possible that the user (un)installs a compiler
          inbetween compilations of object files we want to catch
          that. This method allows compiler choice to be stored in a
          pickled metadata file.  Provide metadir a dirpath to
          make the class save choice there in a file with
          cls.metadata_filename as name.