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