1 | # |
---|
2 | # Script to get source from SVN and build SansView |
---|
3 | # |
---|
4 | # Read the release notes to make ensure that the required software is installed. |
---|
5 | # |
---|
6 | # SVN must be installed: |
---|
7 | # http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91 |
---|
8 | # Make sure svn.exe in on the path. You might need to log out and log back in again after installing SVN. |
---|
9 | # |
---|
10 | # Inno Setup must be installed |
---|
11 | # |
---|
12 | # py2exe must be installed |
---|
13 | # |
---|
14 | # mingw must be installed |
---|
15 | # |
---|
16 | # Usage: |
---|
17 | # python build_sansview [command] |
---|
18 | # [command] can be any of the following: |
---|
19 | # -h: lists the command line options |
---|
20 | # -r: Builds a SansView using the released modules. |
---|
21 | # -t: Builds SansView from the trunk. |
---|
22 | # -i: Builds an installer from the release version. |
---|
23 | # -n: Print out the dependencies for the release notes |
---|
24 | |
---|
25 | import os |
---|
26 | import shutil |
---|
27 | |
---|
28 | PYTHON = "c:\python25\python" |
---|
29 | SVN = "svn" |
---|
30 | INNO = "\"c:\Program Files\Inno Setup 5\ISCC\"" |
---|
31 | |
---|
32 | # Release version 0.1.0 |
---|
33 | SANSMODELS = "0.4.2" |
---|
34 | DATALOADER = "0.2.1" |
---|
35 | GUICOMM = "0.1.1" |
---|
36 | GUIFRAME = "0.1.4" |
---|
37 | SANSVIEW = "0.1.0" |
---|
38 | PLOTTOOLS = "0.1.3" |
---|
39 | UTIL = "0.1" |
---|
40 | PARK = "1.2.x" |
---|
41 | PARK_INTEG = "0.1.0" |
---|
42 | |
---|
43 | SANSMODELS_URL = "svn://danse.us/sans/releases/sansmodels-%s" % SANSMODELS |
---|
44 | DATALOADER_URL = "svn://danse.us/sans/releases/DataLoader-%s" % DATALOADER |
---|
45 | GUICOMM_URL = "svn://danse.us/sans/releases/guicomm-%s" % GUICOMM |
---|
46 | GUIFRAME_URL = "svn://danse.us/sans/releases/guiframe-%s" % GUIFRAME |
---|
47 | PLOTTOOLS_URL = "svn://danse.us/common/releases/plottools-%s/trunk" % PLOTTOOLS |
---|
48 | UTIL_URL = "svn://danse.us/common/releases/util-%s" % UTIL |
---|
49 | SANSVIEW_URL = "svn://danse.us/sans/releases/sansview-%s" % SANSVIEW |
---|
50 | PARK_INTEG_URL = "svn://danse.us/sans/releases/park_integration-%s" % PARK_INTEG |
---|
51 | #TODO: need to use the release branch of PARK once it is created |
---|
52 | PARK_URL = "svn://danse.us/park/branches/park-1.2" |
---|
53 | |
---|
54 | # Installation folder |
---|
55 | import time |
---|
56 | timestamp = int(time.time()) |
---|
57 | INSTALL_FOLDER = "install_%s" % str(timestamp) |
---|
58 | |
---|
59 | |
---|
60 | def check_system(): |
---|
61 | """ |
---|
62 | Checks that the system has the necessary modules. |
---|
63 | """ |
---|
64 | try: |
---|
65 | import wx |
---|
66 | except: |
---|
67 | print "wxpython missing" |
---|
68 | |
---|
69 | try: |
---|
70 | import matplotlib |
---|
71 | except: |
---|
72 | print "matplotlib missing" |
---|
73 | |
---|
74 | try: |
---|
75 | import numpy |
---|
76 | except: |
---|
77 | print "numpy missing" |
---|
78 | |
---|
79 | try: |
---|
80 | import scipy |
---|
81 | except: |
---|
82 | print "scipy missing" |
---|
83 | |
---|
84 | if os.system("gcc -dumpversion")==1: |
---|
85 | print "missing mingw" |
---|
86 | |
---|
87 | def install_pkg(install_dir, setup_dir, url): |
---|
88 | """ |
---|
89 | Check a package out and install it |
---|
90 | |
---|
91 | @param install_dir: directory to put the code in |
---|
92 | @param setup_dir: relative location of the setup.py script |
---|
93 | @param url: URL of the SVN repo |
---|
94 | """ |
---|
95 | if not os.path.isdir(install_dir): |
---|
96 | os.mkdir(install_dir) |
---|
97 | os.chdir(install_dir) |
---|
98 | os.system("%s checkout -q %s" % (SVN, url)) |
---|
99 | os.chdir(setup_dir) |
---|
100 | os.system("%s setup.py build -cmingw32" % PYTHON) |
---|
101 | os.system("%s setup.py install" % PYTHON) |
---|
102 | |
---|
103 | def checkout(release=False): |
---|
104 | """ |
---|
105 | Check the SansView code out |
---|
106 | """ |
---|
107 | wd = os.getcwd() |
---|
108 | |
---|
109 | os.chdir(wd) |
---|
110 | if release: |
---|
111 | install_pkg(".", "sansmodels-%s/src" % SANSMODELS, SANSMODELS_URL) |
---|
112 | else: |
---|
113 | install_pkg(".", "sansmodels/src", "svn://danse.us/sans/trunk/sansmodels") |
---|
114 | |
---|
115 | os.chdir(wd) |
---|
116 | if release: |
---|
117 | install_pkg(".", "DataLoader-%s" % DATALOADER, DATALOADER_URL) |
---|
118 | else: |
---|
119 | install_pkg(".", "DataLoader", "svn://danse.us/sans/trunk/DataLoader") |
---|
120 | |
---|
121 | os.chdir(wd) |
---|
122 | if release: |
---|
123 | install_pkg(".", "guicomm-%s" % GUICOMM, GUICOMM_URL) |
---|
124 | else: |
---|
125 | install_pkg(".", "guicomm", "svn://danse.us/sans/trunk/guicomm") |
---|
126 | |
---|
127 | os.chdir(wd) |
---|
128 | if release: |
---|
129 | install_pkg(".", "guiframe-%s" % GUIFRAME, GUIFRAME_URL) |
---|
130 | else: |
---|
131 | install_pkg(".", "guiframe", "svn://danse.us/sans/trunk/guiframe") |
---|
132 | |
---|
133 | os.chdir(wd) |
---|
134 | if release: |
---|
135 | install_pkg("plottools-%s" % PLOTTOOLS, "trunk", PLOTTOOLS_URL) |
---|
136 | else: |
---|
137 | install_pkg("plottools", "trunk", "svn://danse.us/common/plottools/trunk") |
---|
138 | |
---|
139 | os.chdir(wd) |
---|
140 | if release: |
---|
141 | install_pkg(".", "util-%s" % UTIL, UTIL_URL) |
---|
142 | else: |
---|
143 | install_pkg(".", "util", "svn://danse.us/common/util") |
---|
144 | |
---|
145 | os.chdir(wd) |
---|
146 | if release: |
---|
147 | install_pkg(".", "park_integration-%s" % PARK_INTEG, PARK_INTEG_URL) |
---|
148 | else: |
---|
149 | install_pkg(".", "park_integration", "svn://danse.us/sans/trunk/park_integration") |
---|
150 | |
---|
151 | #TODO: need a release version of PARK |
---|
152 | os.chdir(wd) |
---|
153 | if release: |
---|
154 | install_pkg(".", "park-1.2", PARK_URL) |
---|
155 | else: |
---|
156 | install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2") |
---|
157 | |
---|
158 | os.chdir(wd) |
---|
159 | if release: |
---|
160 | os.system("%s checkout %s" % (SVN, SANSVIEW_URL)) |
---|
161 | else: |
---|
162 | os.system("%s checkout svn://danse.us/sans/trunk/sansview" % SVN) |
---|
163 | |
---|
164 | def prepare(): |
---|
165 | # Create a fresh installation folder |
---|
166 | |
---|
167 | if os.path.isdir(INSTALL_FOLDER): |
---|
168 | shutil.rmtree(INSTALL_FOLDER) |
---|
169 | |
---|
170 | os.mkdir(INSTALL_FOLDER) |
---|
171 | |
---|
172 | # Check that the dependencies are properly installed |
---|
173 | check_system() |
---|
174 | |
---|
175 | # Move to the installation folder |
---|
176 | os.chdir(INSTALL_FOLDER) |
---|
177 | |
---|
178 | if __name__ == "__main__": |
---|
179 | import sys |
---|
180 | |
---|
181 | if len(sys.argv)>1: |
---|
182 | if sys.argv[1]=="-h": |
---|
183 | print "Usage:" |
---|
184 | print " python build_sansview [command]\n" |
---|
185 | print "[command] can be any of the following:" |
---|
186 | print " -h: lists the command line options" |
---|
187 | print " -r: Builds a SansView using the released modules" |
---|
188 | print " -t: Builds SansView from the trunk" |
---|
189 | print " -i: Builds an installer from the release version" |
---|
190 | print " -n: Print out the dependencies for the release notes" |
---|
191 | elif sys.argv[1]=="-n": |
---|
192 | print SANSMODELS_URL |
---|
193 | print DATALOADER_URL |
---|
194 | print GUICOMM_URL |
---|
195 | print GUIFRAME_URL |
---|
196 | print PLOTTOOLS_URL |
---|
197 | print UTIL_URL |
---|
198 | print SANSVIEW_URL |
---|
199 | print PARK_INTEG |
---|
200 | print PARK_URL |
---|
201 | else: |
---|
202 | # Prepare installation folder |
---|
203 | prepare() |
---|
204 | |
---|
205 | # Check the command line argument |
---|
206 | if sys.argv[1]=="-t": |
---|
207 | print "Building trunk version" |
---|
208 | checkout() |
---|
209 | elif sys.argv[1]=="-r": |
---|
210 | print "Building release version" |
---|
211 | checkout(True) |
---|
212 | elif sys.argv[1]=="-i": |
---|
213 | print "Building release version" |
---|
214 | checkout(True) |
---|
215 | print "Building installer from release version" |
---|
216 | os.chdir("sansview-%s" % (SANSVIEW)) |
---|
217 | os.system("%s setup_exe.py py2exe" % PYTHON) |
---|
218 | os.system("%s installer.iss" % INNO) |
---|
219 | |
---|