code: def get_libpath_from_dirlist(libname, dirs):
      
      dirqueue = deque(dirs)
      while (len(dirqueue) > 0):
          nextdir = dirqueue.popleft()
          possible = []
          # Our directory might be no good, so try/except
          try:
              for libfile in os.listdir(nextdir):
                  if fnmatch.fnmatch(libfile,'lib'+libname+'.so*') or \
                          fnmatch.fnmatch(libfile,'lib'+libname+'.dylib*') or \
                          fnmatch.fnmatch(libfile,libname+'.dll') or \
                          fnmatch.fnmatch(libfile,'cyg'+libname+'-*.dll'):
                      possible.append(libfile)
          except OSError:
              pass
          # There might be more than one library found, we want the highest-numbered
          if (len(possible) > 0):
              possible.sort()
              return os.path.join(nextdir,possible[-1])
      # If we get here, we didn't find it...
      return None
docs: This function tries to find the architecture-independent library given by libname in the first
      available directory in the list dirs. 'Architecture-independent' means omitting any prefix such
      as 'lib' or suffix such as 'so' or 'dylib' or version number.  Within the first directory in which
      a matching pattern can be found, the lexicographically first such file is returned, as a string
      giving the full path name.  The only supported OSes at the moment are posix and mac, and this
      function does not attempt to determine which is being run.  So if for some reason your directory
      has both '.so' and '.dylib' libraries, who knows what will happen.  If the library cannot be found,
      None is returned.