bindepend.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 glob
  15. import argparse
  16. import PyInstaller.depend.bindepend
  17. from PyInstaller.compat import is_win
  18. import PyInstaller.log
  19. def run():
  20. parser = argparse.ArgumentParser()
  21. PyInstaller.log.__add_options(parser)
  22. parser.add_argument('filenames', nargs='+',
  23. metavar='executable-or-dynamic-library',
  24. help=("executables or dynamic libraries for which "
  25. "the dependencies should be shown"))
  26. args = parser.parse_args()
  27. PyInstaller.log.__process_options(parser, args)
  28. # Suppress all informative messages from the dependency code.
  29. PyInstaller.log.getLogger('PyInstaller.build.bindepend').setLevel(
  30. PyInstaller.log.WARN)
  31. try:
  32. for a in args.filenames:
  33. for fn in glob.glob(a):
  34. imports = PyInstaller.depend.bindepend.getImports(fn)
  35. if is_win:
  36. assemblies = PyInstaller.depend.bindepend.getAssemblies(fn)
  37. imports.update([a.getid() for a in assemblies])
  38. print(fn, imports)
  39. except KeyboardInterrupt:
  40. raise SystemExit("Aborted by user request.")
  41. if __name__ == '__main__':
  42. run()