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

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 6b33ffc was 24fe25d, checked in by Jae Cho <jhjcho@…>, 13 years ago

log missing periodictable

  • Property mode set to 100644
File size: 12.0 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# On Mac:
20#   - py2app must be installed
21#   - macholib must be installed to use py2app
22#   - modulegraph must be installed to use py2app
23#
24# Usage:
25# python build_sansview [command]
26# [command] can be any of the following:
27#   -h: lists the command line options
28#   -r: Builds a SansView using the released modules.
29#   -t: Builds SansView from the trubuild_sank.
30#   -i: Builds a Windows installer from the release version.
31#   -n: Print out the dependencies for the release notes
32
33import os
34import sys
35import shutil
36import logging
37
38# Installation folder
39import time
40timestamp = int(time.time())
41CWD    = os.getcwd()
42INSTALL_FOLDER = "install_%s" % str(timestamp)
43
44# On Windows, the python executable is not always on the path.
45# Use its most frequent location as the default.
46if sys.platform == 'win32':
47    PYTHON = "c:\python25\python"
48    LIB_FOLDER = "%s/%s" % (CWD, INSTALL_FOLDER)
49else:
50    PYTHON = 'python'
51
52logging.basicConfig(level=logging.INFO,
53                    format='%(asctime)s %(levelname)s %(message)s',
54                    filename='build_%s.log' % str(timestamp),
55                    filemode='w')
56
57SVN    = "svn"
58INNO   = "\"c:\Program Files\Inno Setup 5\ISCC\""
59
60# Release version 1.9
61SANSMODELS = "0.9.1"
62DATALOADER = "0.9"
63GUIFRAME   = "0.9.1"
64SANSVIEW   = "1.9.1"
65PLOTTOOLS  = "0.9.1"
66UTIL       = "0.9.1"
67PARK       = "1.2.1"
68PARK_INTEG = "0.9.1"
69PRVIEW     = "0.9.1"
70PR_INV     = "0.9"
71CALCULATOR = "0.9.1"
72CALC_VIEW  = "0.9"
73INVARIANT  = "0.9.1"
74INV_VIEW   = "0.9"
75
76# URLs for SVN repos
77SANSMODELS_URL = "svn://danse.us/sans/releases/sansmodels-%s" % SANSMODELS
78DATALOADER_URL = "svn://danse.us/sans/releases/DataLoader-%s" % DATALOADER
79GUIFRAME_URL = "svn://danse.us/sans/releases/guiframe-%s" % GUIFRAME
80PLOTTOOLS_URL = "svn://danse.us/common/releases/plottools-%s/trunk" % PLOTTOOLS
81UTIL_URL = "svn://danse.us/common/releases/util-%s" % UTIL
82SANSVIEW_URL = "svn://danse.us/sans/releases/sansview-%s" % SANSVIEW
83PARK_INTEG_URL = "svn://danse.us/sans/releases/park_integration-%s" % PARK_INTEG
84PARK_URL = "svn://danse.us/park/releases/park-%s" % PARK
85PRVIEW_URL = "svn://danse.us/sans/releases/prview-%s" % PRVIEW
86PR_INV_URL = "svn://danse.us/sans/releases/pr_inversion-%s" % PR_INV
87CALC_URL = "svn://danse.us/sans/releases/calculator-%s" % CALCULATOR
88CALC_VIEW_URL = "svn://danse.us/sans/releases/calculatorview-%s" % CALC_VIEW
89INV_URL = "svn://danse.us/sans/releases/Invariant-%s" % INVARIANT
90INV_VIEW_URL = "svn://danse.us/sans/releases/invariantview-%s" % INV_VIEW
91
92def check_system():
93    """
94        Checks that the system has the necessary modules.
95    """
96    try:
97        import wx
98    except:
99        logging.error("wxpython missing")
100   
101    try:
102        import matplotlib
103    except:
104        logging.error("matplotlib missing")
105       
106    try:
107        import numpy
108    except:
109        logging.error("numpy missing")
110       
111    try:
112        import scipy
113    except:
114        logging.error("scipy missing")
115
116    try:
117        import periodictable
118    except:
119        logging.error("periodictable missing")
120       
121    if os.system("gcc -dumpversion")==1:
122        logging.error("missing mingw")
123
124def install_pkg(install_dir, setup_dir, url):
125    """
126        Check a package out and install it
127       
128        @param install_dir: directory to put the code in
129        @param setup_dir: relative location of the setup.py script
130        @param url: URL of the SVN repo
131    """
132    logging.info("Installing %s" % url)
133    try:
134        if not os.path.isdir(install_dir):
135            os.mkdir(install_dir)
136        os.chdir(install_dir)   
137        os.system("%s checkout -q %s" % (SVN, url))       
138        os.chdir(setup_dir)
139        if sys.platform == 'win32':
140            os.system("%s setup.py -q build -cmingw32" % PYTHON)
141            os.system("%s setup.py -q install --root \"%s\"" % (PYTHON, LIB_FOLDER))
142        else:
143            os.system("%s setup.py build" % PYTHON)
144            os.system("%s setup.py install --prefix ~/.local" % PYTHON)
145    except:
146        logging.error("Install failed for %s" % url)
147        logging.error(sys.exc_value)
148        raw_input("Press enter to continue\n")
149        sys.exit()
150   
151def checkout(release=False):
152    """
153        Check the SansView code out
154    """
155    wd = os.getcwd()
156   
157    os.chdir(wd)
158    if release:
159        install_pkg(".", "DataLoader-%s" % DATALOADER, DATALOADER_URL)
160    else:
161        install_pkg(".", "DataLoader", "svn://danse.us/sans/trunk/DataLoader")
162   
163    os.chdir(wd)
164    if release:
165        install_pkg(".", "sansmodels-%s/src" % SANSMODELS, SANSMODELS_URL)
166    else:
167        install_pkg(".", "sansmodels/src", "svn://danse.us/sans/trunk/sansmodels")
168   
169    os.chdir(wd)
170    if release:
171        install_pkg(".", "guiframe-%s" % GUIFRAME, GUIFRAME_URL)
172    else:
173        install_pkg(".", "guiframe", "svn://danse.us/sans/trunk/guiframe")
174   
175    os.chdir(wd)
176    if release:
177        install_pkg("plottools-%s" % PLOTTOOLS, "trunk", PLOTTOOLS_URL)
178    else:
179        install_pkg("plottools", "trunk", "svn://danse.us/common/plottools/trunk")
180   
181    os.chdir(wd)
182    if release:
183        install_pkg(".", "util-%s" % UTIL, UTIL_URL)
184    else:
185        install_pkg(".", "util", "svn://danse.us/common/util")
186   
187    os.chdir(wd)
188    if release:
189        install_pkg(".", "park_integration-%s" % PARK_INTEG, PARK_INTEG_URL)
190    else:
191        install_pkg(".", "park_integration", "svn://danse.us/sans/trunk/park_integration")
192   
193    os.chdir(wd)
194    if release:
195        install_pkg(".", "prview-%s" % PRVIEW, PRVIEW_URL)
196    else:
197        install_pkg(".", "prview", "svn://danse.us/sans/trunk/prview")
198   
199    os.chdir(wd)
200    if release:
201        install_pkg(".", "pr_inversion-%s" % PR_INV, PR_INV_URL)
202    else:
203        install_pkg(".", "pr_inversion", "svn://danse.us/sans/trunk/pr_inversion")
204   
205    os.chdir(wd)
206    if release:
207        install_pkg(".", "Invariant-%s" % INVARIANT, INV_URL)
208    else:
209        install_pkg(".", "Invariant", "svn://danse.us/sans/trunk/Invariant")
210   
211    os.chdir(wd)
212    if release:
213        install_pkg(".", "invariantview-%s" % INV_VIEW, INV_VIEW_URL)
214    else:
215        install_pkg(".", "invariantview", "svn://danse.us/sans/trunk/invariantview")
216   
217    os.chdir(wd)
218    if release:
219        install_pkg(".", "calculatorview-%s" % CALC_VIEW, CALC_VIEW_URL)
220    else:
221        install_pkg(".", "calculatorview", "svn://danse.us/sans/trunk/calculatorview")
222   
223    os.chdir(wd)
224    if release:
225        install_pkg(".", "calculator-%s" % CALCULATOR, CALC_URL)
226    else:
227        install_pkg(".", "calculator", "svn://danse.us/sans/trunk/calculator")
228
229
230    os.chdir(wd)
231    if release:
232        install_pkg(".", "park-%s" % PARK, PARK_URL)
233    else:
234        install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2")
235   
236    os.chdir(wd)
237    if release:
238        os.system("%s checkout -q %s" % (SVN, SANSVIEW_URL))
239    else:
240        os.system("%s checkout -q svn://danse.us/sans/trunk/sansview" % SVN)
241   
242def prepare(wipeout = False):
243    """
244        Prepare the build
245       
246        @param wipeout: If True, the DANSE modules in the standard site-packages will be
247        removed to avoid conflicts.
248    """
249    # Remove existing libraries
250    if wipeout == True:
251        logging.info("Deleting DANSES modules in site-packages")
252        from distutils.sysconfig import get_python_lib
253        libdir = get_python_lib()
254        old_dirs = [os.path.join(libdir, 'danse'),
255                    os.path.join(libdir, 'data_util'),
256                    os.path.join(libdir, 'DataLoader'),
257                    os.path.join(libdir, 'park'),
258                    os.path.join(libdir, 'sans'),
259                    os.path.join(libdir, 'sans_extension'),
260                    ]
261        for d in old_dirs:
262            if os.path.isdir(d):
263                shutil.rmtree(d)
264       
265    # Create a fresh installation folder
266    if os.path.isdir(INSTALL_FOLDER):
267        shutil.rmtree(INSTALL_FOLDER)
268
269    os.mkdir(INSTALL_FOLDER)
270   
271    # Check that the dependencies are properly installed
272    check_system()   
273   
274    # Move to the installation folder
275    os.chdir(INSTALL_FOLDER)   
276
277def warning():
278    """
279        The build script will wipe out part of the site-packages.
280        Ask the user whether he wants to proceed.
281    """
282    print "WARNING!\n"
283    print "In order to build a clean version of SansView, this script"
284    print "deletes anything found under site-packages for the following"
285    print "modules:"
286    print "   - danse"
287    print "   - data_util"
288    print "   - DataLoader"
289    print "   - park"
290    print "   - sans"
291    print "   - sans_extension\n"
292    answer = raw_input("Do you want to delete those modules [Y] or continue with a dirty installation [N]? [Y|N]")
293    return answer.upper()=="Y"
294       
295if __name__ == "__main__": 
296    print "Build script for SansView %s" % SANSVIEW
297   
298    if len(sys.argv)==1:
299        # If there is no argument, build the installer
300        sys.argv.append("-i")
301       
302    if len(sys.argv)>1:
303        # Help
304        if sys.argv[1]=="-h":
305            print "Usage:"
306            print "    python build_sansview [command]\n"
307            print "[command] can be any of the following:"
308            print "    -h: lists the command line options"
309            print "    -r: Builds a SansView using the released modules"
310            print "    -t: Builds SansView from the trunk"
311            print "    -i: Builds an installer from the release version [Windows only]"       
312            print "    -n: Print out the dependencies for the release notes"
313        elif sys.argv[1]=="-n":
314            # Print out release URLs
315            print SANSMODELS_URL
316            print DATALOADER_URL
317            print GUIFRAME_URL
318            print PLOTTOOLS_URL
319            print UTIL_URL
320            print SANSVIEW_URL
321            print PARK_INTEG_URL
322            print PARK_URL
323            print PRVIEW
324            print PR_INV
325        else:
326            logging.info("Build script for SansView %s" % SANSVIEW)
327                   
328            # Prepare installation folder
329            prepare(warning())
330           
331            # Check the command line argument
332            if sys.argv[1]=="-t":
333                logging.info("Building trunk version")
334                checkout()
335            elif sys.argv[1]=="-r":
336                logging.info("Building release version")
337                checkout(True)
338            elif sys.argv[1]=="-i":
339                logging.info("Building release version")
340                checkout(True)
341                if sys.platform=='win32':
342                    logging.info("Building Windows installer from release version")
343                    os.chdir("sansview-%s" % (SANSVIEW))
344                    os.system("%s setup_exe.py py2exe --extrapath \"%s\python25\lib\site-packages\"" % (PYTHON, LIB_FOLDER))
345                    os.system("%s/Q installer.iss" % INNO)
346                    shutil.copy2(os.path.join("Output","setupSansView.exe"), 
347                                 os.path.join(CWD, "setupSansView_%s.exe" % str(timestamp)))
348                elif sys.platform=='darwin':
349                    logging.info("Building Mac application from release version")
350                    os.chdir("sansview-%s" % (SANSVIEW))
351                    os.system("%s setup_mac.py py2app" % PYTHON)                   
352                   
353    raw_input("Press enter to continue\n")
354   
Note: See TracBrowser for help on using the repository browser.