Attempts to find the #Dependency on the system. Returns the filename of the
  native library or None if it can not be found.
768989
def resolve_dependency(dep):
  

  for dirname in os.getenv('PATH', '').split(os.pathsep):
    filename = os.path.join(dirname, dep.name)
    if os.path.isfile(filename):
      return _get_long_path_name(filename)
  return None
398436
private static URL findLibraryResource(final String libraryFileName) {
    String osName = System.getProperty("os.name").toLowerCase();
    String osArch = System.getProperty("os.arch").toLowerCase();
    String resourceName = null;

    LOG.trace("Load library \"{}\" for os {}:{}", libraryFileName, osName, osArch);

    if (osName.startsWith(OS_WIN)) {
      resourceName = determineWindowsLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_LINUX)) {
      resourceName = determineLinuxLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_FREEBSD)) {
      resourceName = determineFreebsdLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_MAC)) {
      resourceName = determineMacLibrary(libraryFileName);
    } else {
      unsupportedPlatform(osName, osArch);
    }

    URL resource = NativeLoader.class.getResource(resourceName);

    if (null == resource) {
      unsupportedPlatform(osName, osArch, resourceName);
    }

    return resource;
  }
522351
def check_dependencies():
    
    available = []
    try:
        shell('ebook-convert')
        available.append('calibre')
    except OSError:
        pass
    try:
        shell('pandoc --help')
        available.append('pandoc')
    except OSError:
        pass
    if not available:
        sys.exit(error('No generator found, you cannot use md2ebook.'))
    check_dependency_epubcheck()
    return available
413927
def find_lib(lib):
	
	"""
	if isinstance(lib, str):
		lib = getattr(ctypes.windll, lib)

	size = 1024
	result = ctypes.create_unicode_buffer(size)
	library.GetModuleFileName(lib._handle, result, size)
	return result.value
1143794
def dependency(self):
        
        from re import match
        if self._kind_module is not None:
            #We have already done this search at some point.
            return self._kind_module.name

        if (self.kind is not None and "len=" not in self.kind.lower()
            and not match("\d", self.kind[0])):
            #Find the module that declares this kind as:
            # 1) derived type
            # 2) parameter/member
            #The good news is that in order for the module being unit tested to compile,
            #it must have a 'use' statement for the derived type. We can just search from
            #that module with a tree find. Also, at the end of the day, it will have to
            #be declared as public, in order to be used in other modules.
            found, foundmod = self.module.parent.tree_find(self.kind.lower(),
                                                           self.module,
                                                           "publics")
            self._kind_module = foundmod #At worst this will be None again
            if found is not None:
                return foundmod.name
327088
def get_dependency_walker():
  

  for dirname in os.getenv('PATH', '').split(os.pathsep):
    filename = os.path.join(dirname, 'depends.exe')
    if os.path.isfile(filename):
      logger.info('Dependency Walker found at "{}"'.format(filename))
      return filename

  temp_exe = os.path.join(tempfile.gettempdir(), 'depends.exe')
  temp_dll = os.path.join(tempfile.gettempdir(), 'depends.dll')
  if os.path.isfile(temp_exe):
    logger.info('Dependency Walker found at "{}"'.format(temp_exe))
    return temp_exe

  logger.info('Dependency Walker not found. Downloading ...')
  with urlopen('http://dependencywalker.com/depends22_x64.zip') as fp:
    data = fp.read()

  logger.info('Extracting Dependency Walker to "{}"'.format(temp_exe))
  with zipfile.ZipFile(io.BytesIO(data)) as fp:
    with fp.open('depends.exe') as src:
      with open(temp_exe, 'wb') as dst:
        shutil.copyfileobj(src, dst)
    with fp.open('depends.dll') as src:
      with open(temp_dll, 'wb') as dst:
        shutil.copyfileobj(src, dst)

  return temp_exe
253931
def get_lib(self, arch='x86', native=False):
        
        if self.sdk_version == 'v7.0A':
            if arch == 'x86':
                arch = ''
            lib = os.path.join(self.sdk_dir, 'lib', arch)
            if os.path.isdir(lib):
                logging.info(_('using lib: %s'), lib)
                return [lib]
            logging.debug(_('lib not found: %s'), lib)
            return []
        if self.sdk_version == 'v8.1':
            if native:
                extra = os.path.join('winv6.3', 'km')
            else:
                extra = os.path.join('winv6.3', 'um')
            lib = os.path.join(self.sdk_dir, 'lib', extra, arch)
            if os.path.isdir(lib):
                logging.info(_('using lib: %s'), lib)
                return [lib]
            logging.debug(_('lib not found: %s'), lib)
            return []
        if self.sdk_version == 'v10.0':
            dirs = []
            extra = os.path.join('lib', '10.0.10240.0')
            for mode in ['um', 'ucrt']:
                lib = os.path.join(self.sdk_dir, extra, mode, arch)
                if os.path.isdir(lib):
                    logging.info(_('using lib: %s'), lib)
                    dirs.append(lib)
                else:
                    logging.debug(_('lib not found: %s'), lib)
            return dirs
        message = 'unknown sdk version: {}'.format(self.sdk_version)
        raise RuntimeError(message)
629658
def get_stdlib_path():
    
    if sys.version_info >= (2, 7):
        import sysconfig
        return sysconfig.get_paths()['stdlib']
    else:
        return os.path.join(sys.prefix, 'lib')
253631
def get_dependency_type(_type):
        
        if _type == DependencyTypes.AFTER:
            return 'after'
        elif _type == DependencyTypes.AFTER_ANY:
            return 'afterany'
        elif _type == DependencyTypes.AFTER_CORR:
            return 'aftercorr'
        elif _type == DependencyTypes.AFTER_NOT_OK:
            return 'afternotok'
        elif _type == DependencyTypes.AFTER_OK:
            return 'afterok'
        else:
            return None
1020046
private static DependencyHintsInfo getPortableExecutableHints(String filename) {
        DependencyHintsInfo hints = null;
        try {
            // parse PE (Portable Executable) file
            PE pe = PEParser.parse(filename);
            ResourceDirectory rd = pe.getImageData().getResourceTable();
            ResourceEntry[] entries = ResourceHelper.findResources(rd, ResourceType.VERSION_INFO);
            byte[] data = entries[0].getData();
            VersionInfo version = ResourceParser.readVersionInfo(data);
            StringFileInfo stringFileInfo = version.getStringFileInfo();
            StringTable table = stringFileInfo.getTable(0);

            // collect general details
            hints = new DependencyHintsInfo();
            for (int i = 0; i < table.getCount(); i++) {
                String value = table.getString(i).getValue();
                if (StringUtils.isNotBlank(value) && !value.equals(MISSING_VALUE)) {
                    switch (table.getString(i).getKey()) {
                        case COMPANY_NAME:
                            hints.setCompanyName(value);
                            break;
                        case FILE_VERSION:
                            hints.setFileVersion(value);
                            break;
                        case COPYRIGHT:
                            hints.setCopyright(value);
                            break;
                        case ORIGINAL_FILE_NAME:
                            hints.setOriginalFilename(value);
                            break;
                        case PRODUCT_NAME:
                            hints.setProductName(value);
                            break;
                        case PRODUCT_VERSION:
                            hints.setProductVersion(value);
                            break;
                        default: break;
                    }
                }
            }

            if (Platform.isWindows()) {
                hints.setIssuerCommonName(executePowerShellCommand(MessageFormat.format(AUTH_CODE_SIGNATURE_ISSUER_PATTERN, filename)));
                hints.setSubjectCommonName(executePowerShellCommand(MessageFormat.format(AUTH_CODE_SIGNATURE_SUBJECT_PATTERN, filename)));
            }

            // TODO handle msi

        } catch (Exception e) {
            // do nothing
        }
        return hints;
    }
934963
def libname(self):
        
        if self.library is not None:
            return "ftypes.{}.so".format(self.library)
        else:
            return "{}.so".format(self.name)
13639
def package_depends_on(self, name_a, name_b):
        
        assert self._context
        if self._dependency_lookup is None:
            self._dependency_graph = self._context.get_dependency_graph()
            self._dependency_lookup = accessibility(self._dependency_graph)

        downstream = self._dependency_lookup.get(name_a, [])
        accessible = (name_b in downstream)
        if accessible:
            neighbours = self._dependency_graph.neighbors(name_a)
            return 2 if name_b in neighbours else 1
        else:
            return 0
753191
private void loadNativeLibraries(File root)
   {
      if (root != null && root.exists())
      {
         List<String> libs = new ArrayList<String>();

         if (root.isDirectory())
         {
            if (root.listFiles() != null)
            {
               for (File f : root.listFiles())
               {
                  if (f.isFile())
                  {
                     String fileName = f.getName().toLowerCase(Locale.US);
                     if (fileName.endsWith(".a") || fileName.endsWith(".so") || fileName.endsWith(".dll"))
                     {
                        libs.add(f.getAbsolutePath());
                     }
                  }
               }
            }
            else
            {
               log.debugf("Root is a directory, but there were an I/O error: %s", root.getAbsolutePath());
            }
         }

         if (libs.size() > 0)
         {
            for (String lib : libs)
            {
               try
               {
                  SecurityActions.load(lib);
                  log.debugf("Loaded library: %s", lib);
               }
               catch (Throwable t)
               {
                  log.debugf("Unable to load library: %s", lib);
               }
            }
         }
         else
         {
            log.debugf("No native libraries for %s", root.getAbsolutePath());
         }
      }
   }
637100
def find_library_file(libname):
    
    # Use a dummy argument parser to get user specified library dirs
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument("--library-dirs", "-L", default='')
    args, unknown = parser.parse_known_args()
    user_lib_dirs = args.library_dirs.split(':')
    # Append default search path (not a complete list)
    lib_dirs = user_lib_dirs + [os.path.join(sys.prefix, 'lib'),
                              '/usr/local/lib',
                              '/usr/lib',
                              '/usr/lib/x86_64-linux-gnu']

    compiler = ccompiler.new_compiler()
    return compiler.find_library_file(lib_dirs, libname)
747526
def find_compilation_database(path):
  """"""
  result = './'
  while not os.path.isfile(os.path.join(result, path)):
    if os.path.realpath(result) == '/':
      print('Error: could not find compilation database.')
      sys.exit(1)
    result += '../'
  return os.path.realpath(result)
648378
def resolve_dep(self, depname):
        
        for d in self._search_path:
            name = os.path.join(d, depname)
            if self._mock:
                return name
            if os.path.exists(name):
                return name
        if self.resolve_dep_from_path(depname):
            # It's a system dep, so skip it
            return None

        message = "unable to find %s in %r" % (depname, self._search_path + self._path)
        print(message)
        # The conditional is to ease future debugging
        if True:
            raise RuntimeError(message)
        return None
572981
def check_dependency(self, dependency_path):
        """"""
        stored_hash = self._stamp_file_hashes.get(dependency_path)

        # This file was newly added, or we don't have a file
        # with stored hashes yet. Assume out of date.
        if not stored_hash:
            return False

        return stored_hash == _sha1_for_file(dependency_path)