PageRenderTime 36ms CodeModel.GetById 24ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/scripts/mkrelease.py

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