source: sasview/sansview/build_sansview.py @ fa58441

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since fa58441 was 249bae9, checked in by Mathieu Doucet <doucetm@…>, 15 years ago

SansView?: Build script

  • Property mode set to 100644
File size: 6.5 KB
Line 
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
25import os
26import shutil
27
28PYTHON = "python"
29SVN    = "svn"
30INNO   = "\"c:\Program Files\Inno Setup 5\ISCC\""
31
32# Release version 0.1.0
33SANSMODELS = "0.4.2"
34DATALOADER = "0.2.1"
35GUICOMM    = "0.1.1"
36GUIFRAME   = "0.1.4"
37SANSVIEW   = "0.1.0"
38PLOTTOOLS  = "0.1.3"
39UTIL       = "0.1"
40PARK       = "1.2.x"
41
42SANSMODELS_URL = "svn://danse.us/sans/releases/sansmodels-%s" % SANSMODELS
43DATALOADER_URL = "svn://danse.us/sans/releases/DataLoader-%s" % DATALOADER
44GUICOMM_URL = "svn://danse.us/sans/releases/guicomm-%s" % GUICOMM
45GUIFRAME_URL = "svn://danse.us/sans/releases/guiframe-%s" % GUIFRAME
46PLOTTOOLS_URL = "svn://danse.us/common/releases/plottools-%s/trunk" % PLOTTOOLS
47UTIL_URL = "svn://danse.us/common/releases/util-%s" % UTIL
48SANSVIEW_URL = "svn://danse.us/sans/releases/sansview-%s" % SANSVIEW
49#TODO: need to use the release branch of PARK once it is created
50PARK_URL = "svn://danse.us/park/branches/park-1.2"
51
52# Installation folder
53import time
54timestamp = int(time.time())
55INSTALL_FOLDER = "install_%s" % str(timestamp)
56
57
58def 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
85def 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)
98    os.system("%s setup.py build -cmingw32" % PYTHON)
99    os.system("%s setup.py install" % PYTHON)
100   
101def checkout(release=False):
102    """
103        Check the SansView code out
104    """
105    wd = os.getcwd()
106   
107    os.chdir(wd)
108    if release:
109        install_pkg(".", "sansmodels-%s/src" % SANSMODELS, SANSMODELS_URL)
110    else:
111        install_pkg(".", "sansmodels/src", "svn://danse.us/sans/trunk/sansmodels")
112   
113    os.chdir(wd)
114    if release:
115        install_pkg(".", "DataLoader-%s" % DATALOADER, DATALOADER_URL)
116    else:
117        install_pkg(".", "DataLoader", "svn://danse.us/sans/trunk/DataLoader")
118   
119    os.chdir(wd)
120    if release:
121        install_pkg(".", "guicomm-%s" % GUICOMM, GUICOMM_URL)
122    else:
123        install_pkg(".", "guicomm", "svn://danse.us/sans/trunk/guicomm")
124   
125    os.chdir(wd)
126    if release:
127        install_pkg(".", "guiframe-%s" % GUIFRAME, GUIFRAME_URL)
128    else:
129        install_pkg(".", "guiframe", "svn://danse.us/sans/trunk/guiframe")
130   
131    os.chdir(wd)
132    if release:
133        install_pkg("plottools-%s" % PLOTTOOLS, "trunk", PLOTTOOLS_URL)
134    else:
135        install_pkg("plottools", "trunk", "svn://danse.us/common/plottools/trunk")
136   
137    os.chdir(wd)
138    if release:
139        install_pkg(".", "util-%s" % UTIL, UTIL_URL)
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:
146        install_pkg(".", "park-1.2", PARK_URL)
147    else:
148        install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2")
149   
150    os.chdir(wd)
151    if release:
152        os.system("%s checkout %s" % (SVN, SANSVIEW_URL))
153    else:
154        os.system("%s checkout svn://danse.us/sans/trunk/sansview" % SVN)
155   
156def 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
170if __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"       
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
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   
Note: See TracBrowser for help on using the repository browser.