docstr: Second-guess the linker with not much hard
  data to go on: GCC seems to prefer the shared library, so
  assume that *all* Unix C compilers do,
  ignoring even GCC's "-static" option.
  
  >>> compiler = UnixCCompiler()
  >>> compiler._library_root = lambda dir: dir
  >>> monkeypatch = getfixture('monkeypatch')
  >>> monkeypatch.setattr(os.path, 'exists', lambda d: 'existing' in d)
  >>> dirs = ('/foo/bar/missing', '/foo/bar/existing')
  >>> compiler.find_library_file(dirs, 'abc').replace('\\', '/')
  '/foo/bar/existing/libabc.dylib'
  >>> compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/')
  '/foo/bar/existing/libabc.dylib'
  >>> monkeypatch.setattr(os.path, 'exists',
  ...     lambda d: 'existing' in d and '.a' in d)
  >>> compiler.find_library_file(dirs, 'abc').replace('\\', '/')
  '/foo/bar/existing/libabc.a'
  >>> compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/')
  '/foo/bar/existing/libabc.a'
docstr_tok: ["Second-guess","the","linker","with","not","much","hard","data","to","go","on",":","GCC","seems","to","prefer","the","shared","library",",","so","assume","that","*","all","*","Unix","C","compilers","do",",","ignoring","even","GCC","'s","``","-static","''","option",".",">",">",">","compiler","=","UnixCCompiler","(",")",">",">",">","compiler._library_root","=","lambda","dir",":","dir",">",">",">","monkeypatch","=","getfixture","(","'monkeypatch","'",")",">",">",">","monkeypatch.setattr","(","os.path",",","'exists","'",",","lambda","d",":","'existing","'","in","d",")",">",">",">","dirs","=","(","'\/foo\/bar\/missing","'",",","'\/foo\/bar\/existing","'",")",">",">",">","compiler.find_library_file","(","dirs",",","'abc","'",")",".replace","(","'\\\\","'",",","'\/","'",")","'\/foo\/bar\/existing\/libabc.dylib'",">",">",">","compiler.find_library_file","(","reversed","(","dirs",")",",","'abc","'",")",".replace","(","'\\\\","'",",","'\/","'",")","'\/foo\/bar\/existing\/libabc.dylib'",">",">",">","monkeypatch.setattr","(","os.path",",","'exists","'",",","...","lambda","d",":","'existing","'","in","d","and","'.a","'","in","d",")",">",">",">","compiler.find_library_file","(","dirs",",","'abc","'",")",".replace","(","'\\\\","'",",","'\/","'",")","'\/foo\/bar\/existing\/libabc.a'",">",">",">","compiler.find_library_file","(","reversed","(","dirs",")",",","'abc","'",")",".replace","(","'\\\\","'",",","'\/","'",")","'\/foo\/bar\/existing\/libabc.a","'"]
code: def find_library_file(self, dirs, lib, debug=0):
      r"""
      Second-guess the linker with not much hard
      data to go on: GCC seems to prefer the shared library, so
      assume that *all* Unix C compilers do,
      ignoring even GCC's "-static" option.
  
      >>> compiler = UnixCCompiler()
      >>> compiler._library_root = lambda dir: dir
      >>> monkeypatch = getfixture('monkeypatch')
      >>> monkeypatch.setattr(os.path, 'exists', lambda d: 'existing' in d)
      >>> dirs = ('/foo/bar/missing', '/foo/bar/existing')
      >>> compiler.find_library_file(dirs, 'abc').replace('\\', '/')
      '/foo/bar/existing/libabc.dylib'
      >>> compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/')
      '/foo/bar/existing/libabc.dylib'
      >>> monkeypatch.setattr(os.path, 'exists',
      ...     lambda d: 'existing' in d and '.a' in d)
      >>> compiler.find_library_file(dirs, 'abc').replace('\\', '/')
      '/foo/bar/existing/libabc.a'
      >>> compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/')
      '/foo/bar/existing/libabc.a'
      """
      lib_names = (
          self.library_filename(lib, lib_type=type)
          for type in "dylib xcode_stub shared static".split()
      )
  
      roots = map(self._library_root, dirs)
  
      searched = (
          os.path.join(root, lib_name)
          for root, lib_name in itertools.product(roots, lib_names)
      )
  
      found = filter(os.path.exists, searched)
  
      # Return None if it could not be found in any dir.
      return next(found, None)
  
imports: import os
  import sys
  import re
  import shlex
  import itertools
  from .None import sysconfig
  from ._modified import newer
  from .ccompiler import CCompiler, gen_preprocess_options, gen_lib_options
  from .errors import DistutilsExecError, CompileError, LibError, LinkError
  from ._log import log
  from ._macos_compat import compiler_fixup
label_desc: Use image node_id 10 for calling the UnixCCompiler obj's underlying member method code with example usage: obj.find_library_file(dirs, lib, debug) and returns: next