-
Notifications
You must be signed in to change notification settings - Fork 5
/
do_release.py
100 lines (78 loc) · 2.53 KB
/
do_release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import sys
import getopt
from subprocess import Popen, PIPE
import os
from release import build_verstring, build_fverstring
import release
def nofailexec(cmd, cwd = None):
p = Popen(cmd, cwd = cwd, shell = True)
p.wait()
assert p.returncode == 0
def make_tarballs(fast = False):
if fast:
cmd = "python setup.py sdist --formats=zip"
else:
cmd = "python setup.py sdist --formats=bztar,zip"
nofailexec(cmd)
def test_sanity():
# This executes numscons unit tests: this is far from covering everything,
# but at least guarantees basic sanity of the package
ver = build_fverstring()
cmd = "tar -xjf numscons-%s.tar.bz2" % ver
nofailexec([cmd], cwd = "dist")
cmd = "PYTHONPATH=%s:$PYTHONPATH python setup.py scons" % \
os.path.join(os.getcwd(), "dist", "numscons-%s" % ver)
nofailexec([cmd], cwd = "dist/numscons-%s/tests" % ver)
def make_eggs():
# Build eggs for 2.5, 2.6 and 2.7
cmd = "python2.5 setupegg.py bdist_egg"
nofailexec([cmd])
cmd = "python2.6 setupegg.py bdist_egg"
nofailexec([cmd])
cmd = "python2.7 setupegg.py bdist_egg"
nofailexec([cmd])
def register():
# Register tarballs and eggs on pypi
cmd = "python setup.py register sdist --formats=bztar,zip upload"
nofailexec([cmd])
cmd = "python2.5 setupegg.py register bdist_egg upload"
nofailexec([cmd])
cmd = "python2.6 setupegg.py register bdist_egg upload"
nofailexec([cmd])
cmd = "python2.7 setupegg.py register bdist_egg upload"
nofailexec([cmd])
def process(arg):
if arg == 'test':
make_tarballs()
test_sanity()
elif arg == 'release':
if release.DEV:
raise Exception("Dev version ?")
make_tarballs()
test_sanity()
make_eggs()
register()
else:
raise ValueError("Unknown option %s" % arg)
USAGE = """Small program to automatize tasks for a numscons release.
Usage:
- %s test: basic sanity checks (numscons import, unit tests)
- %s release: do the release""" % (__file__, __file__)
def main():
# parse command line options
try:
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
except getopt.error, msg:
print msg
print "for help use --help"
sys.exit(2)
# process options
for o, a in opts:
if o in ("-h", "--help"):
print USAGE
sys.exit(0)
# process arguments
for arg in args:
process(arg) # process() is defined elsewhere
if __name__ == '__main__':
main()