Checks if `depends.exe` is in the system PATH. If not, it will be downloaded
  and extracted to a temporary directory. Note that the file will not be
  deleted afterwards.

  Returns the path to the Dependency Walker executable.
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
29014
def which(component, path_str):
    ''''''

    def is_exe(fpath):
        return os.path.exists(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(component)
    if fpath:
        if is_exe(component):
            return component
    else:
        for path in path_str.split(os.pathsep):
            exe_file = os.path.join(path, component)
            if is_exe(exe_file):
                return exe_file
375046
public Map<String,String> getDependenciesPath() {
        Map<String,String> dependenciesMap = new HashMap<String,String>();
        for (Dependency dependency : currentDependencies() ) {
            if ( dependency.getArtifact().getFile() != null ) {
                dependenciesMap.put( Notation.generate( dependency ), dependency.getArtifact().getFile().getAbsolutePath() );
            }
        }
        
        return dependenciesMap;
    }
993942
def get_compiler_path():
    
    # If the user provides a specific solc binary let's use that
    given_binary = os.environ.get('SOLC_BINARY')
    if given_binary:
        return given_binary

    for path in os.getenv('PATH', '').split(os.pathsep):
        path = path.strip('"')
        executable_path = os.path.join(path, BINARY)

        if os.path.isfile(executable_path) and os.access(
                executable_path, os.X_OK):
            return executable_path

    return None
148527
def _find_executables(name):
    
    exe_name = name + '.exe' * sys.platform.startswith('win')
    env_path = os.environ.get(name.upper()+ '_PATH', '')
    
    possible_locations = []
    def add(*dirs):
        for d in dirs:
            if d and d not in possible_locations and os.path.isdir(d):
                possible_locations.append(d)
    
    # Get list of possible locations
    add(env_path)
    try:
        add(os.path.dirname(os.path.abspath(__file__)))
    except NameError:  # __file__ may not exist
        pass
    add(os.path.dirname(sys.executable))
    add(os.path.expanduser('~'))
    
    # Platform specific possible locations
    if sys.platform.startswith('win'):
        add('c:\\program files', os.environ.get('PROGRAMFILES'),
            'c:\\program files (x86)', os.environ.get('PROGRAMFILES(x86)'))
    else:
        possible_locations.extend(['/usr/bin','/usr/local/bin','/opt/local/bin'])
    
    def do_check_version(exe):
        try:
            return subprocess.check_output([exe, '--version']).decode().strip()
        except Exception:
            # print('not a good exe', exe)
            return False
    
    # If env path is the exe itself ...
    if os.path.isfile(env_path):
        ver = do_check_version(env_path)
        if ver:
            return env_path, ver
    
    # First try to find obvious locations
    for d in possible_locations:
        for exe in [os.path.join(d, exe_name), os.path.join(d, name, exe_name)]:
            if os.path.isfile(exe):
                ver = do_check_version(exe)
                if ver:
                    return exe, ver
    
    # Maybe the exe is on the PATH
    ver = do_check_version(exe_name)
    if ver:
        return exe_name, ver
        
    # Try harder
    for d in possible_locations:
        for sub in reversed(sorted(os.listdir(d))):
            if sub.startswith(name):
                exe = os.path.join(d, sub, exe_name)
                if os.path.isfile(exe):
                    ver = do_check_version(exe)
                    if ver:
                        return exe, ver
    
    return None, None
265183
def find_executable(executable, path=None):
  
  if path is None:
    path = os.environ['PATH']
  paths = path.split(os.pathsep)
  base, ext = os.path.splitext(executable)

  if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
    executable = executable + '.exe'

  if not os.path.isfile(executable):
    for p in paths:
      f = os.path.join(p, executable)
      if os.path.isfile(f):
        # the file exists, we have a shot at spawn working
        return f
    return None
  else:
    return executable
1254396
def _locate(self, name):
        
        if name == None:
            raise Exception("Dependency name cannot be null")
        if self._references == None:
            raise Exception("References shall be set")
        
        return self._dependencies.get(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
920745
def __find_executables(path):
    
    
    success = False
    progs = {'dot': '', 'twopi': '', 'neato': '', 'circo': '', 'fdp': '', 'sfdp': ''}
    
    was_quoted = False
    path = path.strip()
    if path.startswith('"') and path.endswith('"'):
        path = path[1:-1]
        was_quoted =  True
    
    if os.path.isdir(path) : 
    
        for prg in progs.iterkeys():
    
            if progs[prg]:
                continue
               
            if os.path.exists( os.path.join(path, prg) ):
                
                if was_quoted:
                    progs[prg] = '"' + os.path.join(path, prg) + '"'
                else:
                    progs[prg] = os.path.join(path, prg)
                    
                success = True
               
            elif os.path.exists( os.path.join(path, prg + '.exe') ):

                if was_quoted:
                    progs[prg] = '"' + os.path.join(path, prg + '.exe') + '"'
                else:
                    progs[prg] = os.path.join(path, prg + '.exe')
                    
                success = True
    
    if success:
    
        return progs
        
    else:
    
        return None
1083548
def depends (self, d):
        
        self.dependencies_ = unique (self.dependencies_ + d).sort ()
374681
def should_repair_executable path
      return (File.exists?(path) && !File.directory?(path) && File.read(path).match(/^\#\!\/bin\/sh/))
    end
654598
private Optional<File> which(final String executableName) {
    String systemPath = System.getenv("PATH");
    String[] pathDirs = systemPath.split(File.pathSeparator);
    
    Optional<File> fullyQualifiedExecutable = Optional.absent();
    for(final String pathDir : pathDirs) {
      File file = new File(pathDir, executableName);
      if (file.isFile()) {
        fullyQualifiedExecutable = Optional.of(file);
        break;
      }
    }
    return fullyQualifiedExecutable;
  }
801376
def _process_dependlist(self, dependlist, anexec, isSubroutine, mode="insert"):
        """"""
        for i in range(len(dependlist)):
            #Since we are looping over all the elements and some will
            #be lists of parameters, we need to skip any items that are lists.
            if isinstance(dependlist[i], list):
                continue

            key = dependlist[i].lower()
            if len(dependlist) > i + 1:
                has_params = isinstance(dependlist[i + 1], list)
            else:
                has_params = False

            #Clean the dependency key to make sure we are only considering valid
            #executable symbols.
            cleanmatch = self.RE_DEPCLEAN.match(key + "(")
            if not cleanmatch:
                continue
            else:
                key = cleanmatch.group("key")

            #We need to handle if and do constructs etc. separately
            if key not in ["then", ",", "", "elseif"] and has_params \
               and not "=" in key and not ">" in key:
                if key in ["if", "do"]:
                    self._process_dependlist(dependlist[i + 1], anexec, False, mode)
                else:
                    #This must be valid call to an executable, add it to the list
                    #with its parameters and then process its parameters list
                    #to see if there are more nested executables
                    if mode == "insert":
                        self._add_dependency(key, dependlist, i, isSubroutine, anexec)
                    elif mode == "delete":
                        #Try and find a dependency already in the executable that 
                        #has the same call signature; then remove it.
                        self._remove_dependency(dependlist, i, isSubroutine, anexec)

                    self._process_dependlist(dependlist[i + 1], anexec, False, mode)
258494
def check_dependencies_remote(args):
    
    cmd = [args.python, '-m', 'depends', args.requirement]
    env = dict(PYTHONPATH=os.path.dirname(__file__))
    return subprocess.check_call(cmd, env=env)
1136517
def program_files(self, executable):
        
        if self._get_version() == 6:
            paths = self.REQUIRED_PATHS_6
        elif self._get_version() > 6:
            paths = self.REQUIRED_PATHS_7_1

        return paths
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
804452
def which(cmd):
    
    def is_exe(fp):
        return os.path.isfile(fp) and os.access(fp, os.X_OK)

    fpath, fname = os.path.split(cmd)
    if fpath:
        if is_exe(cmd):
            return cmd
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            exe_file = os.path.join(path, cmd)
            if is_exe(exe_file):
                return exe_file
    return None