source: sasview/sansview/build_sansview.py @ 8569cb9

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 8569cb9 was d1b43cd, checked in by Mathieu Doucet <doucetm@…>, 15 years ago

sansview: update app builder

  • Property mode set to 100644
File size: 10.6 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#
9#
10# On Windows:
11#   - make sure svn.exe in on the path. You might need to log out and log back in again after installing SVN.
12#
13#   - Inno Setup must be installed
14#
15#   - py2exe must be installed
16#
17#   - mingw must be installed
18#
19# Usage:
20# python build_sansview [command]
21# [command] can be any of the following:
22#   -h: lists the command line options
23#   -r: Builds a SansView using the released modules.
24#   -t: Builds SansView from the trunk.
25#   -i: Builds a Windows installer from the release version.
26#   -n: Print out the dependencies for the release notes
27
28import os
29import sys
30import shutil
31import logging
32
33# Installation folder
34import time
35timestamp = int(time.time())
36INSTALL_FOLDER = "install_%s" % str(timestamp)
37
38logging.basicConfig(level=logging.INFO,
39                    format='%(asctime)s %(levelname)s %(message)s',
40                    filename='build_%s.log' % str(timestamp),
41                    filemode='w')
42
43CWD    = os.getcwd()
44
45# On Windows, the python executable is not always on the path.
46# Use its most frequent location as the default.
47if sys.platform == 'win32':
48    PYTHON = "c:\python25\python"
49else:
50    PYTHON = 'python'
51
52SVN    = "svn"
53INNO   = "\"c:\Program Files\Inno Setup 5\ISCC\""
54
55# Release version 1.0.0
56SANSMODELS = "0.4.5"
57DATALOADER = "0.2.5"
58GUICOMM    = "0.1.3"
59GUIFRAME   = "0.1.8"
60SANSVIEW   = "1.0.0"
61PLOTTOOLS  = "0.1.7"
62UTIL       = "0.1.3"
63PARK       = "1.2"
64PARK_INTEG = "0.1.3"
65PRVIEW     = "0.3.1"
66PR_INV     = "0.2.3"
67
68# URLs for SVN repos
69SANSMODELS_URL = "svn://danse.us/sans/releases/sansmodels-%s" % SANSMODELS
70DATALOADER_URL = "svn://danse.us/sans/releases/DataLoader-%s" % DATALOADER
71GUICOMM_URL = "svn://danse.us/sans/releases/guicomm-%s" % GUICOMM
72GUIFRAME_URL = "svn://danse.us/sans/releases/guiframe-%s" % GUIFRAME
73PLOTTOOLS_URL = "svn://danse.us/common/releases/plottools-%s/trunk" % PLOTTOOLS
74UTIL_URL = "svn://danse.us/common/releases/util-%s" % UTIL
75SANSVIEW_URL = "svn://danse.us/sans/releases/sansview-%s" % SANSVIEW
76PARK_INTEG_URL = "svn://danse.us/sans/releases/park_integration-%s" % PARK_INTEG
77PARK_URL = "svn://danse.us/park/releases/park-%s" % PARK
78PRVIEW_URL = "svn://danse.us/sans/releases/prview-%s" % PRVIEW
79PR_INV_URL = "svn://danse.us/sans/releases/pr_inversion-%s" % PR_INV
80
81
82def check_system():
83    """
84        Checks that the system has the necessary modules.
85    """
86    try:
87        import wx
88    except:
89        logging.error("wxpython missing")
90   
91    try:
92        import matplotlib
93    except:
94        logging.error("matplotlib missing")
95       
96    try:
97        import numpy
98    except:
99        logging.error("numpy missing")
100       
101    try:
102        import scipy
103    except:
104        logging.error("scipy missing")
105       
106    if os.system("gcc -dumpversion")==1:
107        logging.error("missing mingw")
108
109def install_pkg(install_dir, setup_dir, url):
110    """
111        Check a package out and install it
112       
113        @param install_dir: directory to put the code in
114        @param setup_dir: relative location of the setup.py script
115        @param url: URL of the SVN repo
116    """
117    if not os.path.isdir(install_dir):
118        os.mkdir(install_dir)
119    os.chdir(install_dir)   
120    os.system("%s checkout -q %s" % (SVN, url))       
121    os.chdir(setup_dir)
122    os.system("%s setup.py -q build -cmingw32" % PYTHON)
123    os.system("%s setup.py -q install" % PYTHON)
124   
125def checkout(release=False):
126    """
127        Check the SansView code out
128    """
129    wd = os.getcwd()
130   
131    os.chdir(wd)
132    if release:
133        install_pkg(".", "sansmodels-%s/src" % SANSMODELS, SANSMODELS_URL)
134    else:
135        install_pkg(".", "sansmodels/src", "svn://danse.us/sans/trunk/sansmodels")
136   
137    os.chdir(wd)
138    if release:
139        install_pkg(".", "DataLoader-%s" % DATALOADER, DATALOADER_URL)
140    else:
141        install_pkg(".", "DataLoader", "svn://danse.us/sans/trunk/DataLoader")
142   
143    os.chdir(wd)
144    if release:
145        install_pkg(".", "guicomm-%s" % GUICOMM, GUICOMM_URL)
146    else:
147        install_pkg(".", "guicomm", "svn://danse.us/sans/trunk/guicomm")
148   
149    os.chdir(wd)
150    if release:
151        install_pkg(".", "guiframe-%s" % GUIFRAME, GUIFRAME_URL)
152    else:
153        install_pkg(".", "guiframe", "svn://danse.us/sans/trunk/guiframe")
154   
155    os.chdir(wd)
156    if release:
157        install_pkg("plottools-%s" % PLOTTOOLS, "trunk", PLOTTOOLS_URL)
158    else:
159        install_pkg("plottools", "trunk", "svn://danse.us/common/plottools/trunk")
160   
161    os.chdir(wd)
162    if release:
163        install_pkg(".", "util-%s" % UTIL, UTIL_URL)
164    else:
165        install_pkg(".", "util", "svn://danse.us/common/util")
166   
167    os.chdir(wd)
168    if release:
169        install_pkg(".", "park_integration-%s" % PARK_INTEG, PARK_INTEG_URL)
170    else:
171        install_pkg(".", "park_integration", "svn://danse.us/sans/trunk/park_integration")
172   
173    os.chdir(wd)
174    if release:
175        install_pkg(".", "prview-%s" % PRVIEW, PRVIEW_URL)
176    else:
177        install_pkg(".", "prview", "svn://danse.us/sans/trunk/prview")
178   
179    os.chdir(wd)
180    if release:
181        install_pkg(".", "pr_inversion-%s" % PR_INV, PR_INV_URL)
182    else:
183        install_pkg(".", "pr_inversion", "svn://danse.us/sans/trunk/pr_inversion")
184   
185    os.chdir(wd)
186    if release:
187        pass
188    else:
189        install_pkg(".", "Invariant", "svn://danse.us/sans/trunk/Invariant")
190   
191    os.chdir(wd)
192    if release:
193        pass
194    else:
195        install_pkg(".", "invariantview", "svn://danse.us/sans/trunk/invariantview")
196   
197    os.chdir(wd)
198    if release:
199        pass
200    else:
201        install_pkg(".", "calculatorview", "svn://danse.us/sans/trunk/calculatorview")
202   
203    os.chdir(wd)
204    if release:
205        pass
206    else:
207        install_pkg(".", "calculator", "svn://danse.us/sans/trunk/calculator")
208   
209    os.chdir(wd)
210    if release:
211        pass
212    else:
213        install_pkg(".", "theoryview", "svn://danse.us/sans/trunk/theoryview")
214
215    #TODO: need a release version of PARK
216    os.chdir(wd)
217    if release:
218        install_pkg(".", "park-1.2", PARK_URL)
219    else:
220        install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2")
221   
222    os.chdir(wd)
223    if release:
224        os.system("%s checkout -q %s" % (SVN, SANSVIEW_URL))
225    else:
226        os.system("%s checkout -q svn://danse.us/sans/trunk/sansview" % SVN)
227   
228def prepare(wipeout = False):
229    """
230        Prepare the build
231    """
232    # Remove existing libraries
233    if wipeout == True:
234        print "Deleting old modules"
235        from distutils.sysconfig import get_python_lib
236        libdir = get_python_lib()
237        old_dirs = [os.path.join(libdir, 'danse'),
238                    os.path.join(libdir, 'data_util'),
239                    os.path.join(libdir, 'DataLoader'),
240                    os.path.join(libdir, 'park'),
241                    os.path.join(libdir, 'sans'),
242                    os.path.join(libdir, 'sans_extension'),
243                    ]
244        for d in old_dirs:
245            if os.path.isdir(d):
246                shutil.rmtree(d)
247       
248    # Create a fresh installation folder
249    if os.path.isdir(INSTALL_FOLDER):
250        shutil.rmtree(INSTALL_FOLDER)
251
252    os.mkdir(INSTALL_FOLDER)
253   
254    # Check that the dependencies are properly installed
255    check_system()   
256   
257    # Move to the installation folder
258    os.chdir(INSTALL_FOLDER)   
259
260def warning():
261    """
262        The build script will wipe out part of the site-packages.
263        Ask the user whether he wants to proceed.
264    """
265    print "WARNING!\n"
266    print "In order to build a clean version of SansView, this script"
267    print "deletes anything found under site-packages for the following"
268    print "modules:"
269    print "   - danse"
270    print "   - data_util"
271    print "   - DataLoader"
272    print "   - park"
273    print "   - sans"
274    print "   - sans_extension\n"
275    answer = raw_input("Do you want to delete those modules [Y] or continue with a dirty installation [N]? [Y|N]")
276    return answer.upper()=="Y"
277       
278if __name__ == "__main__": 
279    print "Build script for SansView %s" % SANSVIEW
280   
281    if len(sys.argv)==1:
282        # If there is no argument, build the installer
283        sys.argv.append("-i")
284       
285    if len(sys.argv)>1:
286        # Help
287        if sys.argv[1]=="-h":
288            print "Usage:"
289            print "    python build_sansview [command]\n"
290            print "[command] can be any of the following:"
291            print "    -h: lists the command line options"
292            print "    -r: Builds a SansView using the released modules"
293            print "    -t: Builds SansView from the trunk"
294            print "    -i: Builds an installer from the release version [Windows only]"       
295            print "    -n: Print out the dependencies for the release notes"
296        elif sys.argv[1]=="-n":
297            # Print out release URLs
298            print SANSMODELS_URL
299            print DATALOADER_URL
300            print GUICOMM_URL
301            print GUIFRAME_URL
302            print PLOTTOOLS_URL
303            print UTIL_URL
304            print SANSVIEW_URL
305            print PARK_INTEG_URL
306            print PARK_URL
307            print PRVIEW
308            print PR_INV
309        else:
310            logging.info("Build script for SansView %s" % SANSVIEW)
311                   
312            # Prepare installation folder
313            prepare(warning())
314           
315            # Check the command line argument
316            if sys.argv[1]=="-t":
317                logging.info("Building trunk version")
318                checkout()
319            elif sys.argv[1]=="-r":
320                logging.info("Building release version")
321                checkout(True)
322            elif sys.argv[1]=="-i":
323                logging.info("Building release version")
324                checkout(True)
325                if sys.platform=='win32':
326                    logging.info("Building installer from release version")
327                    os.chdir("sansview-%s" % (SANSVIEW))
328                    os.system("%s setup_exe.py -q py2exe" % PYTHON)
329                    os.system("%s/Q installer.iss" % INNO)
330                    shutil.copy2(os.path.join("Output","setupSansView.exe"), 
331                                 os.path.join(CWD, "setupSansView_%s.exe" % str(timestamp)))
332                   
333   
Note: See TracBrowser for help on using the repository browser.