set_version.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. import argparse
  12. import os
  13. def run():
  14. parser = argparse.ArgumentParser()
  15. parser.add_argument(
  16. 'info_file',
  17. metavar='info-file',
  18. help="text file containing version info",
  19. )
  20. parser.add_argument(
  21. 'exe_file',
  22. metavar='exe-file',
  23. help="full pathname of a Windows executable",
  24. )
  25. args = parser.parse_args()
  26. info_file = os.path.abspath(args.info_file)
  27. exe_file = os.path.abspath(args.exe_file)
  28. try:
  29. import PyInstaller.utils.win32.versioninfo
  30. PyInstaller.utils.win32.versioninfo.SetVersion(exe_file, info_file)
  31. print(('Version info set in: %s' % exe_file))
  32. except KeyboardInterrupt:
  33. raise SystemExit("Aborted by user request.")
  34. if __name__ == '__main__':
  35. run()