source: sasview/sansview/build_sansview.py @ 860afc1

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 860afc1 was 690003a, checked in by Mathieu Doucet <doucetm@…>, 15 years ago

sansview: updated release notes and build script

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