source: sasview/sansview/build_sansview.py @ 6fb01b6

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 6fb01b6 was 7b35808, checked in by Mathieu Doucet <doucetm@…>, 16 years ago

sansview: build script: logging facility, clean up before install, copy of final installer to desktop

  • Property mode set to 100644
File size: 8.2 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
27import logging
28
29# Installation folder
30import time
31timestamp = int(time.time())
32INSTALL_FOLDER = "install_%s" % str(timestamp)
33
34logging.basicConfig(level=logging.INFO,
35                    format='%(asctime)s %(levelname)s %(message)s',
36                    filename='build_%s.log' % str(timestamp),
37                    filemode='w')
38
39CWD    = os.getcwd()
40PYTHON = "c:\python25\python"
41SVN    = "svn"
42INNO   = "\"c:\Program Files\Inno Setup 5\ISCC\""
43
44# Release version 0.1.0
45SANSMODELS = "0.4.2"
46DATALOADER = "0.2.1"
47GUICOMM    = "0.1.1"
48GUIFRAME   = "0.1.4"
49SANSVIEW   = "0.1.0"
50PLOTTOOLS  = "0.1.3"
51UTIL       = "0.1"
52PARK       = "1.2.x"
53PARK_INTEG = "0.1.0"
54
55# URLs for SVN repos
56SANSMODELS_URL = "svn://danse.us/sans/releases/sansmodels-%s" % SANSMODELS
57DATALOADER_URL = "svn://danse.us/sans/releases/DataLoader-%s" % DATALOADER
58GUICOMM_URL = "svn://danse.us/sans/releases/guicomm-%s" % GUICOMM
59GUIFRAME_URL = "svn://danse.us/sans/releases/guiframe-%s" % GUIFRAME
60PLOTTOOLS_URL = "svn://danse.us/common/releases/plottools-%s/trunk" % PLOTTOOLS
61UTIL_URL = "svn://danse.us/common/releases/util-%s" % UTIL
62SANSVIEW_URL = "svn://danse.us/sans/releases/sansview-%s" % SANSVIEW
63PARK_INTEG_URL = "svn://danse.us/sans/releases/park_integration-%s" % PARK_INTEG
64#TODO: need to use the release branch of PARK once it is created
65PARK_URL = "svn://danse.us/park/branches/park-1.2"
66
67
68def check_system():
69    """
70        Checks that the system has the necessary modules.
71    """
72    try:
73        import wx
74    except:
75        logging.error("wxpython missing")
76   
77    try:
78        import matplotlib
79    except:
80        logging.error("matplotlib missing")
81       
82    try:
83        import numpy
84    except:
85        logging.error("numpy missing")
86       
87    try:
88        import scipy
89    except:
90        logging.error("scipy missing")
91       
92    if os.system("gcc -dumpversion")==1:
93        logging.error("missing mingw")
94
95def install_pkg(install_dir, setup_dir, url):
96    """
97        Check a package out and install it
98       
99        @param install_dir: directory to put the code in
100        @param setup_dir: relative location of the setup.py script
101        @param url: URL of the SVN repo
102    """
103    if not os.path.isdir(install_dir):
104        os.mkdir(install_dir)
105    os.chdir(install_dir)   
106    os.system("%s checkout -q %s" % (SVN, url))       
107    os.chdir(setup_dir)
108    os.system("%s setup.py -q build -cmingw32" % PYTHON)
109    os.system("%s setup.py -q install" % PYTHON)
110   
111def checkout(release=False):
112    """
113        Check the SansView code out
114    """
115    wd = os.getcwd()
116   
117    os.chdir(wd)
118    if release:
119        install_pkg(".", "sansmodels-%s/src" % SANSMODELS, SANSMODELS_URL)
120    else:
121        install_pkg(".", "sansmodels/src", "svn://danse.us/sans/trunk/sansmodels")
122   
123    os.chdir(wd)
124    if release:
125        install_pkg(".", "DataLoader-%s" % DATALOADER, DATALOADER_URL)
126    else:
127        install_pkg(".", "DataLoader", "svn://danse.us/sans/trunk/DataLoader")
128   
129    os.chdir(wd)
130    if release:
131        install_pkg(".", "guicomm-%s" % GUICOMM, GUICOMM_URL)
132    else:
133        install_pkg(".", "guicomm", "svn://danse.us/sans/trunk/guicomm")
134   
135    os.chdir(wd)
136    if release:
137        install_pkg(".", "guiframe-%s" % GUIFRAME, GUIFRAME_URL)
138    else:
139        install_pkg(".", "guiframe", "svn://danse.us/sans/trunk/guiframe")
140   
141    os.chdir(wd)
142    if release:
143        install_pkg("plottools-%s" % PLOTTOOLS, "trunk", PLOTTOOLS_URL)
144    else:
145        install_pkg("plottools", "trunk", "svn://danse.us/common/plottools/trunk")
146   
147    os.chdir(wd)
148    if release:
149        install_pkg(".", "util-%s" % UTIL, UTIL_URL)
150    else:
151        install_pkg(".", "util", "svn://danse.us/common/util")
152   
153    os.chdir(wd)
154    if release:
155        install_pkg(".", "park_integration-%s" % PARK_INTEG, PARK_INTEG_URL)
156    else:
157        install_pkg(".", "park_integration", "svn://danse.us/sans/trunk/park_integration")
158   
159    #TODO: need a release version of PARK
160    os.chdir(wd)
161    if release:
162        install_pkg(".", "park-1.2", PARK_URL)
163    else:
164        install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2")
165   
166    os.chdir(wd)
167    if release:
168        os.system("%s checkout -q %s" % (SVN, SANSVIEW_URL))
169    else:
170        os.system("%s checkout -q svn://danse.us/sans/trunk/sansview" % SVN)
171   
172def prepare():
173    """
174        Prepare the build
175    """
176    # Remove existing libraries
177    from distutils.sysconfig import get_python_lib
178    libdir = get_python_lib()
179    old_dirs = [os.path.join(libdir, 'danse'),
180                os.path.join(libdir, 'data_util'),
181                os.path.join(libdir, 'DataLoader'),
182                os.path.join(libdir, 'park'),
183                os.path.join(libdir, 'sans'),
184                os.path.join(libdir, 'sans_extension'),
185                ]
186    for d in old_dirs:
187        if os.path.isdir(d):
188            shutil.rmtree(d)
189   
190    # Create a fresh installation folder
191    if os.path.isdir(INSTALL_FOLDER):
192        shutil.rmtree(INSTALL_FOLDER)
193
194    os.mkdir(INSTALL_FOLDER)
195   
196    # Check that the dependencies are properly installed
197    check_system()   
198   
199    # Move to the installation folder
200    os.chdir(INSTALL_FOLDER)   
201
202if __name__ == "__main__": 
203    import sys
204   
205    print "Build script for SansView %s" % SANSVIEW
206   
207    if len(sys.argv)==1:
208        # If there is no argument, build the installer
209        sys.argv.append("-i")
210       
211    if len(sys.argv)>1:
212        # Help
213        if sys.argv[1]=="-h":
214            print "Usage:"
215            print "    python build_sansview [command]\n"
216            print "[command] can be any of the following:"
217            print "    -h: lists the command line options"
218            print "    -r: Builds a SansView using the released modules"
219            print "    -t: Builds SansView from the trunk"
220            print "    -i: Builds an installer from the release version"       
221            print "    -n: Print out the dependencies for the release notes"
222        elif sys.argv[1]=="-n":
223            # Print out release URLs
224            print SANSMODELS_URL
225            print DATALOADER_URL
226            print GUICOMM_URL
227            print GUIFRAME_URL
228            print PLOTTOOLS_URL
229            print UTIL_URL
230            print SANSVIEW_URL
231            print PARK_INTEG
232            print PARK_URL
233        else:
234            logging.info("Build script for SansView %s" % SANSVIEW)
235            # Prepare installation folder
236            prepare()
237           
238            # Check the command line argument
239            if sys.argv[1]=="-t":
240                logging.info("Building trunk version")
241                checkout()
242            elif sys.argv[1]=="-r":
243                logging.info("Building release version")
244                checkout(True)
245            elif sys.argv[1]=="-i":
246                logging.info("Building release version")
247                checkout(True)
248                logging.info("Building installer from release version")
249                os.chdir("sansview-%s" % (SANSVIEW))
250                os.system("%s setup_exe.py -q py2exe" % PYTHON)
251                os.system("%s/Q installer.iss" % INNO)
252                shutil.copy2(os.path.join("Output","setupSansView.exe"), 
253                             os.path.join(CWD, "setupSansView_%s.exe" % str(timestamp)))
254               
255   
Note: See TracBrowser for help on using the repository browser.