def get_dependency_walker():
  """
  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.
  """

  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
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
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.