def locate_library(candidates, find_library=ctypes.util.find_library):
 if (find_library is None):
  find_library = ctypes.util.find_library
 use_dll_workaround = ((sys.platform == 'win32') and (find_library is ctypes.util.find_library))
 for candidate in candidates:
  if use_dll_workaround:
   candidate += '.dll'
  libname = find_library(candidate)
  if libname:
   return libname
 return None

def locate_library ( candidates , find_library = ctypes . util . find_library ) : if ( find_library is None ) : find_library = ctypes . util . find_library use_dll_workaround = ( ( sys . platform == 'win32' ) and ( find_library is ctypes . util . find_library ) ) for candidate in candidates : if use_dll_workaround : candidate += '.dll' libname = find_library ( candidate ) if libname : return libname return None
tries to locate a library listed in candidates using the given find_library() function .