makespec.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2013-2023, 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. Automatically build a spec file containing the description of the project.
  13. """
  14. import argparse
  15. import os
  16. import PyInstaller.building.makespec
  17. import PyInstaller.log
  18. try:
  19. from argcomplete import autocomplete
  20. except ImportError:
  21. def autocomplete(parser):
  22. return None
  23. def generate_parser():
  24. p = argparse.ArgumentParser()
  25. PyInstaller.building.makespec.__add_options(p)
  26. PyInstaller.log.__add_options(p)
  27. p.add_argument(
  28. 'scriptname',
  29. nargs='+',
  30. )
  31. return p
  32. def run():
  33. p = generate_parser()
  34. autocomplete(p)
  35. args = p.parse_args()
  36. PyInstaller.log.__process_options(p, args)
  37. # Split pathex by using the path separator.
  38. temppaths = args.pathex[:]
  39. args.pathex = []
  40. for p in temppaths:
  41. args.pathex.extend(p.split(os.pathsep))
  42. try:
  43. name = PyInstaller.building.makespec.main(args.scriptname, **vars(args))
  44. print('Wrote %s.' % name)
  45. print('Now run pyinstaller.py to build the executable.')
  46. except KeyboardInterrupt:
  47. raise SystemExit("Aborted by user request.")
  48. if __name__ == '__main__':
  49. run()