source: sasview/sansview/build_sansview.py @ d4fd13c

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 d4fd13c was 138ac69, checked in by Mathieu Doucet <doucetm@…>, 16 years ago

sansview: modify build script to default to simple checkout of the release version on non-windows platforms.

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