bindepend.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2013-2021, PyInstaller Development Team.
  3. #
  4. # Distributed under the terms of the GNU General Public License (version 2
  5. # or later) with exception for distributing the bootloader.
  6. #
  7. # The full license is in the file COPYING.txt, distributed with this software.
  8. #
  9. # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
  10. #-----------------------------------------------------------------------------
  11. """
  12. Show dll dependencies of executable files or other dynamic libraries.
  13. """
  14. import argparse
  15. import glob
  16. import PyInstaller.depend.bindepend
  17. import PyInstaller.log
  18. from PyInstaller.compat import is_win
  19. def run():
  20. parser = argparse.ArgumentParser()
  21. PyInstaller.log.__add_options(parser)
  22. parser.add_argument(
  23. 'filenames',
  24. nargs='+',
  25. metavar='executable-or-dynamic-library',
  26. help="executables or dynamic libraries for which the dependencies should be shown",
  27. )
  28. args = parser.parse_args()
  29. PyInstaller.log.__process_options(parser, args)
  30. # Suppress all informative messages from the dependency code.
  31. PyInstaller.log.getLogger('PyInstaller.build.bindepend').setLevel(PyInstaller.log.WARN)
  32. try:
  33. for a in args.filenames:
  34. for fn in glob.glob(a):
  35. imports = PyInstaller.depend.bindepend.getImports(fn)
  36. if is_win:
  37. assemblies = PyInstaller.depend.bindepend.getAssemblies(fn)
  38. imports.update([a.getid() for a in assemblies])
  39. print(fn, imports)
  40. except KeyboardInterrupt:
  41. raise SystemExit("Aborted by user request.")
  42. if __name__ == '__main__':
  43. run()