-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_release.py
executable file
·76 lines (62 loc) · 2.81 KB
/
build_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
#! /usr/bin/env python
from argparse import ArgumentParser, ArgumentTypeError
import os, sys, subprocess, shutil
"""
Create a release package for distribution
"""
def main():
parser = ArgumentParser(description='Build iDiffIR release')
parser.add_argument('version', type=str, help='version number')
parser.add_argument('-v', '--verbose', dest='verbose',
action='store_true', default='False',
help='Print verbose output')
parser.add_argument('-f', '--force-overwrite', dest='force',
action='store_true', default='False',
help='Force overwrite the directory if it exists')
nspace = parser.parse_args()
nspace.outdir = 'iDiffIR_v%s/' % nspace.version
if os.path.exists(nspace.outdir):
if not nspace.force:
sys.exit('%s exists, use -f to overwrite\n' % nspace.outdir)
else:
shutil.rmtree(nspace.outdir)
os.makedirs(nspace.outdir)
os.makedirs(os.path.join(nspace.outdir, 'doc'))
os.makedirs(os.path.join(nspace.outdir, 'doc', 'pdf'))
else:
os.makedirs(nspace.outdir)
os.makedirs(os.path.join(nspace.outdir, 'doc', 'pdf'))
cmd = 'cp -R %s %s'
# copy license
status_copy = subprocess.call(cmd % ('LICENSE', nspace.outdir),
shell=True)
# copy README
status_copy = subprocess.call(cmd % ('README', nspace.outdir),
shell=True)
# copy CONTRIBUTORS
status_copy = subprocess.call(cmd % ('CONTRIBUTORS', nspace.outdir),
shell=True)
# copy setup.py
status_copy = subprocess.call(cmd % ('setup.py', nspace.outdir),
shell=True)
# copy scripts dir
status_copy = subprocess.call(cmd % ('scripts', nspace.outdir),
shell=True)
# copy iDiffIR dir
status_copy = subprocess.call(cmd % ('iDiffIR', nspace.outdir),
shell=True)
# copy documentation build
if os.path.exists('doc/_build/html') and \
os.path.exists('doc/_build/latex/iDiffIR.pdf'):
status_copy = subprocess.call(cmd % ('doc/_build/html',
os.path.join(nspace.outdir,
'doc')),
shell=True)
status_copy = subprocess.call(cmd % ('doc/_build/latex/iDiffIR.pdf',
os.path.join(nspace.outdir,
'doc', 'pdf')),
shell=True)
else:
sys.stderr.write('Missing documentation directories\n')
if __name__ == "__main__":
main()