templates.py 3.6 KB

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