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 | # Usage: |
---|
15 | # python build_sansview [command] |
---|
16 | # [command] can be any of the following: |
---|
17 | # -h: lists the command line options |
---|
18 | # -r: Builds a SansView using the released modules. |
---|
19 | # -t: Builds SansView from the trunk. |
---|
20 | # -i: Builds an installer from the release version. |
---|
21 | |
---|
22 | import os |
---|
23 | import shutil |
---|
24 | |
---|
25 | PYTHON = "c:\python25\python" |
---|
26 | SVN = "svn" |
---|
27 | INNO = "\"c:\Program Files\Inno Setup 5\ISCC\"" |
---|
28 | |
---|
29 | # Release version 0.1.0 |
---|
30 | SANSMODELS = "0.4.2" |
---|
31 | DATALOADER = "0.2.1" |
---|
32 | GUICOMM = "0.1.1" |
---|
33 | GUIFRAME = "0.1.4" |
---|
34 | SANSVIEW = "0.1.0" |
---|
35 | PLOTTOOLS = "0.1.3" |
---|
36 | UTIL = "0.1" |
---|
37 | |
---|
38 | # Installation folder |
---|
39 | import time |
---|
40 | timestamp = int(time.time()) |
---|
41 | INSTALL_FOLDER = "install_%s" % str(timestamp) |
---|
42 | |
---|
43 | |
---|
44 | def check_system(): |
---|
45 | """ |
---|
46 | Checks that the system has the necessary modules. |
---|
47 | """ |
---|
48 | try: |
---|
49 | import wx |
---|
50 | except: |
---|
51 | print "wxpython missing" |
---|
52 | |
---|
53 | try: |
---|
54 | import matplotlib |
---|
55 | except: |
---|
56 | print "matplotlib missing" |
---|
57 | |
---|
58 | try: |
---|
59 | import numpy |
---|
60 | except: |
---|
61 | print "numpy missing" |
---|
62 | |
---|
63 | try: |
---|
64 | import scipy |
---|
65 | except: |
---|
66 | print "scipy missing" |
---|
67 | |
---|
68 | if os.system("gcc -dumpversion")==1: |
---|
69 | print "missing mingw" |
---|
70 | |
---|
71 | def install_pkg(install_dir, setup_dir, url): |
---|
72 | """ |
---|
73 | Check a package out and install it |
---|
74 | |
---|
75 | @param install_dir: directory to put the code in |
---|
76 | @param setup_dir: relative location of the setup.py script |
---|
77 | @param url: URL of the SVN repo |
---|
78 | """ |
---|
79 | if not os.path.isdir(install_dir): |
---|
80 | os.mkdir(install_dir) |
---|
81 | os.chdir(install_dir) |
---|
82 | os.system("%s checkout -q %s" % (SVN, url)) |
---|
83 | os.chdir(setup_dir) |
---|
84 | os.system("%s setup.py install" % PYTHON) |
---|
85 | |
---|
86 | def checkout(release=False): |
---|
87 | """ |
---|
88 | Check the SansView code out |
---|
89 | """ |
---|
90 | wd = os.getcwd() |
---|
91 | |
---|
92 | os.chdir(wd) |
---|
93 | if release: |
---|
94 | install_pkg(".", "sansmodels-%s/src" % SANSMODELS, "svn://danse.us/sans/releases/sansmodels-%s" % SANSMODELS) |
---|
95 | else: |
---|
96 | install_pkg(".", "sansmodels/src", "svn://danse.us/sans/trunk/sansmodels") |
---|
97 | |
---|
98 | os.chdir(wd) |
---|
99 | if release: |
---|
100 | install_pkg(".", "DataLoader-%s" % DATALOADER, "svn://danse.us/sans/releases/DataLoader-%s" % DATALOADER) |
---|
101 | else: |
---|
102 | install_pkg(".", "DataLoader", "svn://danse.us/sans/trunk/DataLoader") |
---|
103 | |
---|
104 | os.chdir(wd) |
---|
105 | if release: |
---|
106 | install_pkg(".", "guicomm-%s" % GUICOMM, "svn://danse.us/sans/releases/guicomm-%s" % GUICOMM) |
---|
107 | else: |
---|
108 | install_pkg(".", "guicomm", "svn://danse.us/sans/trunk/guicomm") |
---|
109 | |
---|
110 | os.chdir(wd) |
---|
111 | if release: |
---|
112 | install_pkg(".", "guiframe-%s" % GUIFRAME, "svn://danse.us/sans/releases/guiframe-%s" % GUIFRAME) |
---|
113 | else: |
---|
114 | install_pkg(".", "guiframe", "svn://danse.us/sans/trunk/guiframe") |
---|
115 | |
---|
116 | os.chdir(wd) |
---|
117 | if release: |
---|
118 | install_pkg("plottools-%s" % PLOTTOOLS, "trunk", "svn://danse.us/common/releases/plottools-%s/trunk" % PLOTTOOLS) |
---|
119 | else: |
---|
120 | install_pkg("plottools", "trunk", "svn://danse.us/common/plottools/trunk") |
---|
121 | |
---|
122 | os.chdir(wd) |
---|
123 | if release: |
---|
124 | install_pkg(".", "util-%s" % UTIL, "svn://danse.us/common/releases/util-%s" % UTIL) |
---|
125 | else: |
---|
126 | install_pkg(".", "util", "svn://danse.us/common/util") |
---|
127 | |
---|
128 | #TODO: need a release version of PARK |
---|
129 | os.chdir(wd) |
---|
130 | if release: |
---|
131 | install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2") |
---|
132 | else: |
---|
133 | install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2") |
---|
134 | |
---|
135 | os.chdir(wd) |
---|
136 | if release: |
---|
137 | os.system("%s checkout svn://danse.us/sans/releases/sansview-%s" % (SVN, SANSVIEW)) |
---|
138 | else: |
---|
139 | os.system("%s checkout svn://danse.us/sans/trunk/sansview" % SVN) |
---|
140 | |
---|
141 | def prepare(): |
---|
142 | # Create a fresh installation folder |
---|
143 | |
---|
144 | if os.path.isdir(INSTALL_FOLDER): |
---|
145 | shutil.rmtree(INSTALL_FOLDER) |
---|
146 | |
---|
147 | os.mkdir(INSTALL_FOLDER) |
---|
148 | |
---|
149 | # Check that the dependencies are properly installed |
---|
150 | check_system() |
---|
151 | |
---|
152 | # Move to the installation folder |
---|
153 | os.chdir(INSTALL_FOLDER) |
---|
154 | |
---|
155 | if __name__ == "__main__": |
---|
156 | import sys |
---|
157 | |
---|
158 | if len(sys.argv)>1: |
---|
159 | if sys.argv[1]=="-h": |
---|
160 | print "Usage:" |
---|
161 | print " python build_sansview [command]\n" |
---|
162 | print "[command] can be any of the following:" |
---|
163 | print " -h: lists the command line options" |
---|
164 | print " -r: Builds a SansView using the released modules" |
---|
165 | print " -t: Builds SansView from the trunk" |
---|
166 | print " -i: Builds an installer from the release version" |
---|
167 | else: |
---|
168 | # Prepare installation folder |
---|
169 | prepare() |
---|
170 | |
---|
171 | # Check the command line argument |
---|
172 | if sys.argv[1]=="-t": |
---|
173 | print "Building trunk version" |
---|
174 | checkout() |
---|
175 | elif sys.argv[1]=="-r": |
---|
176 | print "Building release version" |
---|
177 | checkout(True) |
---|
178 | elif sys.argv[1]=="-i": |
---|
179 | print "Building release version" |
---|
180 | checkout(True) |
---|
181 | print "Building installer from release version" |
---|
182 | os.chdir("sansview-%s" % (SANSVIEW)) |
---|
183 | os.system("%s setup_exe.py py2exe" % PYTHON) |
---|
184 | os.system("%s installer.iss" % INNO) |
---|
185 | |
---|