PageRenderTime 32ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/build_release.py

http://crunchy.googlecode.com/
Python | 123 lines | 104 code | 12 blank | 7 comment | 10 complexity | a92302e177f2d2d2a123820514f3f1d4 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. """
  4. build_release.py
  5. Created by Johannes Woolard on 2008-04-14.
  6. """
  7. import sys
  8. from subprocess import call
  9. import pysvn
  10. help_message = '''build_release.py
  11. Usage: python build_release version targets
  12. targets should be a space separated list. If no target is given, then the source will be downloaded
  13. but no targets will be built. The following targets are currently supported:
  14. * zip
  15. * tar.gz
  16. Run this from an empty directory - it will download the appropriate release version from
  17. http://crunchy.googlecode.com/svn/tags/'version' (where version is the version given as
  18. an argument to te command).
  19. IMPORTANT: Always run this from an empty directory.
  20. Final release files will end up in the curent working directory.
  21. This script relies on pysvn from http://pysvn.tigris.org/
  22. '''
  23. def main(argv=None):
  24. if argv is None:
  25. argv = sys.argv
  26. if len(argv) < 2:
  27. sys.stderr.write(help_message)
  28. return 2
  29. version = argv[1]
  30. print "Creating dist packages for Crunchy, version %s" % version
  31. print "Exporting dist from http://crunchy.googlecode.com/svn/tags/%s" % version
  32. client = pysvn.Client()
  33. revision = client.export("http://crunchy.googlecode.com/svn/tags/%s" % version,
  34. "./crunchy-%s"%version)
  35. print "Successfully exported revision %s from http://crunchy.googlecode.com/svn/tags/%s" % \
  36. (revision.number, version)
  37. if "zip" in argv:
  38. create_zip(version)
  39. if "tar.gz" in argv:
  40. create_targz(version)
  41. #this doesn't work yet :(
  42. if "mac" in argv:
  43. build_mac_app(version)
  44. if "deb" in argv:
  45. print "deb file creation not currently supported"
  46. if "rpm" in argv:
  47. print "rpm file creation not currently supported"
  48. if "py2exe" in argv:
  49. print "py2exe not currently supported"
  50. if "nsis" in argv:
  51. print "nsis not currently supported"
  52. if "msi" in argv:
  53. print "msi file creation not currently supported"
  54. return 0
  55. def create_zip(version):
  56. print "Creating crunchy-%s.zip" % version
  57. retcode = call(["/usr/bin/zip", "-q", "-r", "crunchy-%s.zip" % version, "crunchy-%s" % version])
  58. if retcode == 0:
  59. print "zip file succesfully created"
  60. else:
  61. raise "zip returned error code %s" % retcode
  62. def create_targz(version):
  63. print "Creating crunchy-%s.tar.gz" % version
  64. retcode = call(["/usr/bin/tar", "-czf", "crunchy-%s.tar.gz" % version, "crunchy-%s/" % version])
  65. if retcode == 0:
  66. print "tar.gz file succesfully created"
  67. else:
  68. raise "tar returned error code %s" % retcode
  69. def build_mac_app(version):
  70. print "Creating setup.py for OSX .app"
  71. f = open("setup.py", 'w')
  72. f.write("""
  73. from setuptools import setup
  74. APP = ['crunchy-%s/crunchy.py']
  75. DATA_FILES = ['crunchy-%s/translations',
  76. 'crunchy-%s/server_root',
  77. 'crunchy-%s/LICENSE.txt',
  78. 'crunchy-%s/src/plugins']
  79. OPTIONS = {'argv_emulation': True}
  80. setup(
  81. app=APP,
  82. data_files=DATA_FILES,
  83. options={'py2app': OPTIONS},
  84. setup_requires=['py2app'],
  85. )
  86. """ % (version, version, version, version, version))
  87. f.close()
  88. print "Created setup.py, running py2app"
  89. retcode = call(["/usr/bin/python", "setup.py", "py2app", "-s"])
  90. if retcode == 0:
  91. print ".app file succesfully created - you will have to put it into a .dmg manually"
  92. else:
  93. raise ("py2app returned error code %s" % retcode)
  94. if __name__ == "__main__":
  95. sys.exit(main())