source: sasview/sansview/build_sansview.py @ dffee80

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

sansview: modified builder

  • Property mode set to 100644
File size: 9.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 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(wipeout = False):
180    """
181        Prepare the build
182    """
183    # Remove existing libraries
184    if wipeout == True:
185        print "Deleting old modules"
186        from distutils.sysconfig import get_python_lib
187        libdir = get_python_lib()
188        old_dirs = [os.path.join(libdir, 'danse'),
189                    os.path.join(libdir, 'data_util'),
190                    os.path.join(libdir, 'DataLoader'),
191                    os.path.join(libdir, 'park'),
192                    os.path.join(libdir, 'sans'),
193                    os.path.join(libdir, 'sans_extension'),
194                    ]
195        for d in old_dirs:
196            if os.path.isdir(d):
197                shutil.rmtree(d)
198       
199    # Create a fresh installation folder
200    if os.path.isdir(INSTALL_FOLDER):
201        shutil.rmtree(INSTALL_FOLDER)
202
203    os.mkdir(INSTALL_FOLDER)
204   
205    # Check that the dependencies are properly installed
206    check_system()   
207   
208    # Move to the installation folder
209    os.chdir(INSTALL_FOLDER)   
210
211def warning():
212    """
213        The build script will wipe out part of the site-packages.
214        Ask the user whether he wants to proceed.
215    """
216    print "WARNING!\n"
217    print "In order to build a clean version of SansView, this script"
218    print "deletes anything found under site-packages for the following"
219    print "modules:"
220    print "   - danse"
221    print "   - data_util"
222    print "   - DataLoader"
223    print "   - park"
224    print "   - sans"
225    print "   - sans_extension\n"
226    answer = raw_input("Do you want to delete those modules [Y] or continue with a dirty installation [N]? [Y|N]")
227    return answer.upper()=="Y"
228       
229if __name__ == "__main__": 
230    print "Build script for SansView %s" % SANSVIEW
231   
232    if len(sys.argv)==1:
233        # If there is no argument, build the installer
234        sys.argv.append("-i")
235       
236    if len(sys.argv)>1:
237        # Help
238        if sys.argv[1]=="-h":
239            print "Usage:"
240            print "    python build_sansview [command]\n"
241            print "[command] can be any of the following:"
242            print "    -h: lists the command line options"
243            print "    -r: Builds a SansView using the released modules"
244            print "    -t: Builds SansView from the trunk"
245            print "    -i: Builds an installer from the release version [Windows only]"       
246            print "    -n: Print out the dependencies for the release notes"
247        elif sys.argv[1]=="-n":
248            # Print out release URLs
249            print SANSMODELS_URL
250            print DATALOADER_URL
251            print GUICOMM_URL
252            print GUIFRAME_URL
253            print PLOTTOOLS_URL
254            print UTIL_URL
255            print SANSVIEW_URL
256            print PARK_INTEG_URL
257            print PARK_URL
258        else:
259            logging.info("Build script for SansView %s" % SANSVIEW)
260                   
261            # Prepare installation folder
262            prepare(warning())
263           
264            # Check the command line argument
265            if sys.argv[1]=="-t":
266                logging.info("Building trunk version")
267                checkout()
268            elif sys.argv[1]=="-r":
269                logging.info("Building release version")
270                checkout(True)
271            elif sys.argv[1]=="-i":
272                logging.info("Building release version")
273                checkout(True)
274                if sys.platform=='win32':
275                    logging.info("Building installer from release version")
276                    os.chdir("sansview-%s" % (SANSVIEW))
277                    os.system("%s setup_exe.py -q py2exe" % PYTHON)
278                    os.system("%s/Q installer.iss" % INNO)
279                    shutil.copy2(os.path.join("Output","setupSansView.exe"), 
280                                 os.path.join(CWD, "setupSansView_%s.exe" % str(timestamp)))
281                   
282   
Note: See TracBrowser for help on using the repository browser.