def _search(self, name: str, search_dirs: T.List[T.Optional[str]], exclude_paths: T.Optional[T.List[str]]) -> T.List[T.Optional[str]]:
        '''
        Search in the specified dirs for the specified executable by name
        and if not found search in PATH
        '''
        for search_dir in search_dirs:
            commands = self._search_dir(name, search_dir)
            if commands:
                return commands
        # If there is a directory component, do not look in PATH
        if os.path.dirname(name) and not os.path.isabs(name):
            return [None]
        # Do a standard search in PATH
        path = os.environ.get('PATH', os.defpath)
        if mesonlib.is_windows() and path:
            path = self._windows_sanitize_path(path)
        if exclude_paths:
            paths = OrderedSet(path.split(os.pathsep)).difference(exclude_paths)
            path = os.pathsep.join(paths)
        command = shutil.which(name, path=path)
        if mesonlib.is_windows():
            return self._search_windows_special_cases(name, command, exclude_paths)
        # On UNIX-like platforms, shutil.which() is enough to find
        # all executables whether in PATH or with an absolute path
        return [command]

        Search in the specified dirs for the specified executable by name
        and if not found search in PATH
        
mesonbuild/programs.py