buildexe.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # This builds an .exe out of Tweebox for use with Windows.
  2. # Call this with this command line: buildexe.py
  3. # py2exe is inserted as a command line parameter automatically.
  4. import sys, os
  5. import py2exe # pylint: disable=unused-import,import-error
  6. from distutils.core import setup
  7. from version import versionString
  8. manifest = '''
  9. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  10. <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  11. <assemblyIdentity
  12. version="1.3.5.1"
  13. processorArchitecture="x86"
  14. name="%(prog)s"
  15. type="win32"
  16. />
  17. <description>%(prog)s Program</description>
  18. <dependency>
  19. <dependentAssembly>
  20. <assemblyIdentity
  21. type="win32"
  22. name="Microsoft.VC90.CRT"
  23. version="9.0.30729.6161"
  24. processorArchitecture="X86"
  25. publicKeyToken="1fc8b3b9a1e18e3b"
  26. language="*"
  27. />
  28. </dependentAssembly>
  29. </dependency>
  30. </assembly>
  31. '''
  32. # Force use of py2exe for building Win32.exe
  33. sys.argv.append('py2exe')
  34. # Clear out the dist/win32 directory
  35. for root, dirs, files in os.walk('dist' + os.sep + 'win32', topdown=False):
  36. for name in files:
  37. os.remove(os.path.join(root, name))
  38. for name in dirs:
  39. os.rmdir(os.path.join(root, name))
  40. # Build the exe
  41. setup(
  42. name = 'Twine',
  43. description = 'Twine',
  44. version = versionString,
  45. windows = [{
  46. 'script': 'app.py',
  47. 'icon_resources': [(0x0004, 'appicons\\app.ico'), (0x0005, 'appicons\\doc.ico')],
  48. 'dest_base': 'twine',
  49. 'other_resources': [(24, 1, manifest % dict(prog='Twine'))],
  50. }],
  51. data_files = [
  52. ('targets' + os.sep + 'jonah', ['targets' + os.sep + 'jonah' + os.sep + 'header.html',
  53. 'targets' + os.sep + 'jonah' + os.sep + 'code.js']),
  54. ('targets' + os.sep + 'sugarcane', ['targets' + os.sep + 'sugarcane' + os.sep + 'header.html',
  55. 'targets' + os.sep + 'sugarcane' + os.sep + 'code.js']),
  56. ('targets' + os.sep + 'Responsive', ['targets' + os.sep + 'Responsive' + os.sep + 'header.html']),
  57. ('targets', [
  58. 'targets' + os.sep + 'engine.js',
  59. 'targets' + os.sep + 'jquery.js',
  60. 'targets' + os.sep + 'modernizr.js']),
  61. ('icons', [
  62. # toolbar icons
  63. 'icons' + os.sep + 'newpassage.png',
  64. 'icons' + os.sep + 'zoomin.png',
  65. 'icons' + os.sep + 'zoomout.png',
  66. 'icons' + os.sep + 'zoomfit.png',
  67. 'icons' + os.sep + 'zoom1.png',
  68. 'icons' + os.sep + 'zoomfit.png',
  69. # other icons
  70. 'icons' + os.sep + 'brokenemblem.png',
  71. 'icons' + os.sep + 'externalemblem.png',
  72. 'appicons' + os.sep + 'app.ico',
  73. ]),
  74. ],
  75. options = {
  76. 'py2exe': {
  77. 'dist_dir': 'dist' + os.sep + 'win32',
  78. 'bundle_files': 3,
  79. 'optimize': 2,
  80. 'ignores': ['_scproxy'],
  81. 'dll_excludes': ['w9xpopen.exe', 'MSVCP90.dll'],
  82. 'compressed': True,
  83. }
  84. },
  85. zipfile = 'library.zip',
  86. )
  87. print 'Check the ./dist/win32 folder'