templates.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-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. Templates to generate .spec files.
  13. """
  14. onefiletmplt = """# -*- mode: python ; coding: utf-8 -*-
  15. %(preamble)s
  16. %(cipher_init)s
  17. a = Analysis(%(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. win_no_prefer_redirects=%(win_no_prefer_redirects)s,
  27. win_private_assemblies=%(win_private_assemblies)s,
  28. cipher=block_cipher,
  29. noarchive=%(noarchive)s)
  30. pyz = PYZ(a.pure, a.zipped_data,
  31. cipher=block_cipher)
  32. %(splash_init)s
  33. exe = EXE(pyz,
  34. a.scripts,
  35. a.binaries,
  36. a.zipfiles,
  37. a.datas, %(splash_target)s %(splash_binaries)s
  38. %(options)s,
  39. name='%(name)s',
  40. debug=%(debug_bootloader)s,
  41. bootloader_ignore_signals=%(bootloader_ignore_signals)s,
  42. strip=%(strip)s,
  43. upx=%(upx)s,
  44. upx_exclude=%(upx_exclude)s,
  45. runtime_tmpdir=%(runtime_tmpdir)r,
  46. console=%(console)s,
  47. disable_windowed_traceback=%(disable_windowed_traceback)s,
  48. target_arch=%(target_arch)r,
  49. codesign_identity=%(codesign_identity)r,
  50. entitlements_file=%(entitlements_file)r %(exe_options)s)
  51. """
  52. onedirtmplt = """# -*- mode: python ; coding: utf-8 -*-
  53. %(preamble)s
  54. %(cipher_init)s
  55. a = Analysis(%(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. win_no_prefer_redirects=%(win_no_prefer_redirects)s,
  65. win_private_assemblies=%(win_private_assemblies)s,
  66. cipher=block_cipher,
  67. noarchive=%(noarchive)s)
  68. pyz = PYZ(a.pure, a.zipped_data,
  69. cipher=block_cipher)
  70. %(splash_init)s
  71. exe = EXE(pyz,
  72. a.scripts, %(splash_target)s
  73. %(options)s,
  74. exclude_binaries=True,
  75. name='%(name)s',
  76. debug=%(debug_bootloader)s,
  77. bootloader_ignore_signals=%(bootloader_ignore_signals)s,
  78. strip=%(strip)s,
  79. upx=%(upx)s,
  80. console=%(console)s,
  81. disable_windowed_traceback=%(disable_windowed_traceback)s,
  82. target_arch=%(target_arch)r,
  83. codesign_identity=%(codesign_identity)r,
  84. entitlements_file=%(entitlements_file)r %(exe_options)s)
  85. coll = COLLECT(exe,
  86. a.binaries,
  87. a.zipfiles,
  88. a.datas, %(splash_binaries)s
  89. strip=%(strip)s,
  90. upx=%(upx)s,
  91. upx_exclude=%(upx_exclude)s,
  92. name='%(name)s')
  93. """
  94. cipher_absent_template = """
  95. block_cipher = None
  96. """
  97. cipher_init_template = """
  98. block_cipher = pyi_crypto.PyiBlockCipher(key=%(key)r)
  99. """
  100. bundleexetmplt = """app = BUNDLE(exe,
  101. name='%(name)s.app',
  102. icon=%(icon)s,
  103. bundle_identifier=%(bundle_identifier)s)
  104. """
  105. bundletmplt = """app = BUNDLE(coll,
  106. name='%(name)s.app',
  107. icon=%(icon)s,
  108. bundle_identifier=%(bundle_identifier)s)
  109. """
  110. splashtmpl = """splash = Splash(%(splash_image)r,
  111. binaries=a.binaries,
  112. datas=a.datas,
  113. text_pos=None,
  114. text_size=12,
  115. minify_script=True)
  116. """