source: sasview/sansview/build_sansview.py @ 531a811c

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

sansview: added warning to build script (which is meant for production/non-dev machine for building)

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