/scripts/mkrelease.py

https://bitbucket.org/jpellerin/nose/ · Python · 79 lines · 47 code · 18 blank · 14 comment · 6 complexity · a2bf07ceba171a2736ef0e206828d05d MD5 · raw file

  1. #!/usr/bin/env python2.6
  2. #
  3. #
  4. # create and upload a release
  5. import os
  6. import sys
  7. import urllib
  8. from urllib2 import urlopen
  9. from commands import getstatusoutput
  10. success = 0
  11. sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
  12. import nose
  13. version = nose.__version__
  14. SIMULATE = 'exec' not in sys.argv
  15. if SIMULATE:
  16. print("# simulated run: run as scripts/mkrelease.py exec "
  17. "to execute commands")
  18. def runcmd(cmd):
  19. print cmd
  20. if not SIMULATE:
  21. (status,output) = getstatusoutput(cmd)
  22. if status != success:
  23. sys.stderr.write(output)
  24. sys.stderr.write("\n")
  25. raise Exception('command did not exit successfully')
  26. def cd(dir):
  27. print "cd %s" % dir
  28. if not SIMULATE:
  29. os.chdir(dir)
  30. def main():
  31. tag = 'release_%s' % version
  32. # create tag
  33. runcmd("hg tag -fm 'Tagged release %s' %s" %
  34. (version, tag))
  35. # clone a fresh copy
  36. runcmd('hg clone -r %s . /tmp/nose_%s' % (tag, tag))
  37. # build release in clone
  38. cd('/tmp/nose_%s' % tag)
  39. # remove dev tag from setup
  40. runcmd('cp setup.cfg.release setup.cfg')
  41. # build included docs, run tests
  42. runcmd('tox')
  43. # make the distributions
  44. runcmd('python setup.py sdist upload -s')
  45. # TODO(Kumar) put this back when this bug is fixed:
  46. # http://bugs.python.org/issue10571
  47. # runcmd('python3.2 setup.py bdist_egg upload -s')
  48. runcmd('python setup.py register')
  49. rtd = 'http://readthedocs.org/build/1137'
  50. print 'POST %s' % rtd
  51. if not SIMULATE:
  52. u = urlopen(rtd,
  53. # send dummy params to force a POST
  54. urllib.urlencode({'build': 1}))
  55. print u.read()
  56. u.close()
  57. print '*'
  58. print "* it's live! Now you can show/hide old releases on PyPI"
  59. print '*'
  60. if __name__ == '__main__':
  61. main()