templates.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-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. Templates to generate .spec files.
  13. """
  14. onefiletmplt = """# -*- mode: python ; coding: utf-8 -*-
  15. %(preamble)s
  16. a = Analysis(
  17. %(scripts)s,
  18. pathex=%(pathex)s,
  19. binaries=%(binaries)s,
  20. datas=%(datas)s,
  21. hiddenimports=%(hiddenimports)s,
  22. hookspath=%(hookspath)r,
  23. hooksconfig={},
  24. runtime_hooks=%(runtime_hooks)r,
  25. excludes=%(excludes)s,
  26. noarchive=%(noarchive)s,
  27. optimize=%(optimize)r,
  28. )
  29. pyz = PYZ(a.pure)
  30. %(splash_init)s
  31. exe = EXE(
  32. pyz,
  33. a.scripts,
  34. a.binaries,
  35. a.datas,%(splash_target)s%(splash_binaries)s
  36. %(options)s,
  37. name='%(name)s',
  38. debug=%(debug_bootloader)s,
  39. bootloader_ignore_signals=%(bootloader_ignore_signals)s,
  40. strip=%(strip)s,
  41. upx=%(upx)s,
  42. upx_exclude=%(upx_exclude)s,
  43. runtime_tmpdir=%(runtime_tmpdir)r,
  44. console=%(console)s,
  45. disable_windowed_traceback=%(disable_windowed_traceback)s,
  46. argv_emulation=%(argv_emulation)r,
  47. target_arch=%(target_arch)r,
  48. codesign_identity=%(codesign_identity)r,
  49. entitlements_file=%(entitlements_file)r,%(exe_options)s
  50. )
  51. """
  52. onedirtmplt = """# -*- mode: python ; coding: utf-8 -*-
  53. %(preamble)s
  54. a = Analysis(
  55. %(scripts)s,
  56. pathex=%(pathex)s,
  57. binaries=%(binaries)s,
  58. datas=%(datas)s,
  59. hiddenimports=%(hiddenimports)s,
  60. hookspath=%(hookspath)r,
  61. hooksconfig={},
  62. runtime_hooks=%(runtime_hooks)r,
  63. excludes=%(excludes)s,
  64. noarchive=%(noarchive)s,
  65. optimize=%(optimize)r,
  66. )
  67. pyz = PYZ(a.pure)
  68. %(splash_init)s
  69. exe = EXE(
  70. pyz,
  71. a.scripts,%(splash_target)s
  72. %(options)s,
  73. exclude_binaries=True,
  74. name='%(name)s',
  75. debug=%(debug_bootloader)s,
  76. bootloader_ignore_signals=%(bootloader_ignore_signals)s,
  77. strip=%(strip)s,
  78. upx=%(upx)s,
  79. console=%(console)s,
  80. disable_windowed_traceback=%(disable_windowed_traceback)s,
  81. argv_emulation=%(argv_emulation)r,
  82. target_arch=%(target_arch)r,
  83. codesign_identity=%(codesign_identity)r,
  84. entitlements_file=%(entitlements_file)r,%(exe_options)s
  85. )
  86. coll = COLLECT(
  87. exe,
  88. a.binaries,
  89. a.datas,%(splash_binaries)s
  90. strip=%(strip)s,
  91. upx=%(upx)s,
  92. upx_exclude=%(upx_exclude)s,
  93. name='%(name)s',
  94. )
  95. """
  96. bundleexetmplt = """app = BUNDLE(
  97. exe,
  98. name='%(name)s.app',
  99. icon=%(icon)s,
  100. bundle_identifier=%(bundle_identifier)s,
  101. )
  102. """
  103. bundletmplt = """app = BUNDLE(
  104. coll,
  105. name='%(name)s.app',
  106. icon=%(icon)s,
  107. bundle_identifier=%(bundle_identifier)s,
  108. )
  109. """
  110. splashtmpl = """splash = Splash(
  111. %(splash_image)r,
  112. binaries=a.binaries,
  113. datas=a.datas,
  114. text_pos=None,
  115. text_size=12,
  116. minify_script=True,
  117. always_on_top=True,%(splash_options)s
  118. )
  119. """