source: sasview/sansview/build_sansview.py @ 6546e4b

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

sansview: update app builder

  • Property mode set to 100644
File size: 10.6 KB
RevLine 
[40f9745]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#
[b81af72]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.
[40f9745]12#
[b81af72]13#   - Inno Setup must be installed
14#
15#   - py2exe must be installed
16#
17#   - mingw must be installed
[249bae9]18#
[40f9745]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.
[b81af72]25#   -i: Builds a Windows installer from the release version.
[249bae9]26#   -n: Print out the dependencies for the release notes
[40f9745]27
28import os
[138ac69]29import sys
[40f9745]30import shutil
[7b35808]31import logging
[40f9745]32
[7b35808]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()
[138ac69]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
[40f9745]52SVN    = "svn"
53INNO   = "\"c:\Program Files\Inno Setup 5\ISCC\""
54
[690003a]55# Release version 1.0.0
[b81af72]56SANSMODELS = "0.4.5"
57DATALOADER = "0.2.5"
58GUICOMM    = "0.1.3"
59GUIFRAME   = "0.1.8"
[690003a]60SANSVIEW   = "1.0.0"
[b81af72]61PLOTTOOLS  = "0.1.7"
62UTIL       = "0.1.3"
[d9d68ba]63PARK       = "1.2"
[b81af72]64PARK_INTEG = "0.1.3"
65PRVIEW     = "0.3.1"
66PR_INV     = "0.2.3"
[249bae9]67
[7b35808]68# URLs for SVN repos
[249bae9]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
[fa523d3]76PARK_INTEG_URL = "svn://danse.us/sans/releases/park_integration-%s" % PARK_INTEG
[d9d68ba]77PARK_URL = "svn://danse.us/park/releases/park-%s" % PARK
[b81af72]78PRVIEW_URL = "svn://danse.us/sans/releases/prview-%s" % PRVIEW
79PR_INV_URL = "svn://danse.us/sans/releases/pr_inversion-%s" % PR_INV
[40f9745]80
81
82def check_system():
83    """
84        Checks that the system has the necessary modules.
85    """
86    try:
87        import wx
88    except:
[7b35808]89        logging.error("wxpython missing")
[40f9745]90   
91    try:
92        import matplotlib
93    except:
[7b35808]94        logging.error("matplotlib missing")
[40f9745]95       
96    try:
97        import numpy
98    except:
[7b35808]99        logging.error("numpy missing")
[40f9745]100       
101    try:
102        import scipy
103    except:
[7b35808]104        logging.error("scipy missing")
[40f9745]105       
106    if os.system("gcc -dumpversion")==1:
[7b35808]107        logging.error("missing mingw")
[40f9745]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)
[7b35808]122    os.system("%s setup.py -q build -cmingw32" % PYTHON)
123    os.system("%s setup.py -q install" % PYTHON)
[40f9745]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:
[249bae9]133        install_pkg(".", "sansmodels-%s/src" % SANSMODELS, SANSMODELS_URL)
[40f9745]134    else:
135        install_pkg(".", "sansmodels/src", "svn://danse.us/sans/trunk/sansmodels")
136   
137    os.chdir(wd)
138    if release:
[249bae9]139        install_pkg(".", "DataLoader-%s" % DATALOADER, DATALOADER_URL)
[40f9745]140    else:
141        install_pkg(".", "DataLoader", "svn://danse.us/sans/trunk/DataLoader")
142   
143    os.chdir(wd)
144    if release:
[249bae9]145        install_pkg(".", "guicomm-%s" % GUICOMM, GUICOMM_URL)
[40f9745]146    else:
147        install_pkg(".", "guicomm", "svn://danse.us/sans/trunk/guicomm")
148   
149    os.chdir(wd)
150    if release:
[249bae9]151        install_pkg(".", "guiframe-%s" % GUIFRAME, GUIFRAME_URL)
[40f9745]152    else:
153        install_pkg(".", "guiframe", "svn://danse.us/sans/trunk/guiframe")
154   
155    os.chdir(wd)
156    if release:
[249bae9]157        install_pkg("plottools-%s" % PLOTTOOLS, "trunk", PLOTTOOLS_URL)
[40f9745]158    else:
159        install_pkg("plottools", "trunk", "svn://danse.us/common/plottools/trunk")
160   
161    os.chdir(wd)
162    if release:
[249bae9]163        install_pkg(".", "util-%s" % UTIL, UTIL_URL)
[40f9745]164    else:
165        install_pkg(".", "util", "svn://danse.us/common/util")
166   
[fa523d3]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   
[b81af72]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   
[d1b43cd]185    os.chdir(wd)
186    if release:
187        pass
188    else:
189        install_pkg(".", "Invariant", "svn://danse.us/sans/trunk/Invariant")
190   
191    os.chdir(wd)
192    if release:
193        pass
194    else:
195        install_pkg(".", "invariantview", "svn://danse.us/sans/trunk/invariantview")
196   
197    os.chdir(wd)
198    if release:
199        pass
200    else:
201        install_pkg(".", "calculatorview", "svn://danse.us/sans/trunk/calculatorview")
202   
203    os.chdir(wd)
204    if release:
205        pass
206    else:
207        install_pkg(".", "calculator", "svn://danse.us/sans/trunk/calculator")
208   
209    os.chdir(wd)
210    if release:
211        pass
212    else:
213        install_pkg(".", "theoryview", "svn://danse.us/sans/trunk/theoryview")
214
[40f9745]215    #TODO: need a release version of PARK
216    os.chdir(wd)
217    if release:
[249bae9]218        install_pkg(".", "park-1.2", PARK_URL)
[40f9745]219    else:
220        install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2")
221   
222    os.chdir(wd)
223    if release:
[7b35808]224        os.system("%s checkout -q %s" % (SVN, SANSVIEW_URL))
[40f9745]225    else:
[7b35808]226        os.system("%s checkout -q svn://danse.us/sans/trunk/sansview" % SVN)
[40f9745]227   
[b81cf5c]228def prepare(wipeout = False):
[7b35808]229    """
230        Prepare the build
231    """
232    # Remove existing libraries
[b81cf5c]233    if wipeout == True:
234        print "Deleting old modules"
235        from distutils.sysconfig import get_python_lib
236        libdir = get_python_lib()
237        old_dirs = [os.path.join(libdir, 'danse'),
238                    os.path.join(libdir, 'data_util'),
239                    os.path.join(libdir, 'DataLoader'),
240                    os.path.join(libdir, 'park'),
241                    os.path.join(libdir, 'sans'),
242                    os.path.join(libdir, 'sans_extension'),
243                    ]
244        for d in old_dirs:
245            if os.path.isdir(d):
246                shutil.rmtree(d)
247       
[7b35808]248    # Create a fresh installation folder
[40f9745]249    if os.path.isdir(INSTALL_FOLDER):
250        shutil.rmtree(INSTALL_FOLDER)
251
252    os.mkdir(INSTALL_FOLDER)
253   
254    # Check that the dependencies are properly installed
255    check_system()   
256   
257    # Move to the installation folder
258    os.chdir(INSTALL_FOLDER)   
259
[531a811c]260def warning():
261    """
262        The build script will wipe out part of the site-packages.
263        Ask the user whether he wants to proceed.
264    """
[b81cf5c]265    print "WARNING!\n"
[531a811c]266    print "In order to build a clean version of SansView, this script"
267    print "deletes anything found under site-packages for the following"
268    print "modules:"
269    print "   - danse"
270    print "   - data_util"
271    print "   - DataLoader"
272    print "   - park"
273    print "   - sans"
274    print "   - sans_extension\n"
[b81cf5c]275    answer = raw_input("Do you want to delete those modules [Y] or continue with a dirty installation [N]? [Y|N]")
[531a811c]276    return answer.upper()=="Y"
277       
[40f9745]278if __name__ == "__main__": 
[6e2fe95]279    print "Build script for SansView %s" % SANSVIEW
280   
281    if len(sys.argv)==1:
282        # If there is no argument, build the installer
283        sys.argv.append("-i")
284       
[40f9745]285    if len(sys.argv)>1:
[6e2fe95]286        # Help
[40f9745]287        if sys.argv[1]=="-h":
288            print "Usage:"
289            print "    python build_sansview [command]\n"
290            print "[command] can be any of the following:"
291            print "    -h: lists the command line options"
292            print "    -r: Builds a SansView using the released modules"
293            print "    -t: Builds SansView from the trunk"
[138ac69]294            print "    -i: Builds an installer from the release version [Windows only]"       
[249bae9]295            print "    -n: Print out the dependencies for the release notes"
[fa523d3]296        elif sys.argv[1]=="-n":
[6e2fe95]297            # Print out release URLs
[249bae9]298            print SANSMODELS_URL
299            print DATALOADER_URL
300            print GUICOMM_URL
301            print GUIFRAME_URL
302            print PLOTTOOLS_URL
303            print UTIL_URL
[fa523d3]304            print SANSVIEW_URL
[cd40805]305            print PARK_INTEG_URL
[249bae9]306            print PARK_URL
[b81af72]307            print PRVIEW
308            print PR_INV
[40f9745]309        else:
[7b35808]310            logging.info("Build script for SansView %s" % SANSVIEW)
[b81cf5c]311                   
[40f9745]312            # Prepare installation folder
[b81cf5c]313            prepare(warning())
[40f9745]314           
315            # Check the command line argument
316            if sys.argv[1]=="-t":
[7b35808]317                logging.info("Building trunk version")
[40f9745]318                checkout()
319            elif sys.argv[1]=="-r":
[7b35808]320                logging.info("Building release version")
[40f9745]321                checkout(True)
322            elif sys.argv[1]=="-i":
[7b35808]323                logging.info("Building release version")
[40f9745]324                checkout(True)
[138ac69]325                if sys.platform=='win32':
326                    logging.info("Building installer from release version")
327                    os.chdir("sansview-%s" % (SANSVIEW))
328                    os.system("%s setup_exe.py -q py2exe" % PYTHON)
329                    os.system("%s/Q installer.iss" % INNO)
330                    shutil.copy2(os.path.join("Output","setupSansView.exe"), 
331                                 os.path.join(CWD, "setupSansView_%s.exe" % str(timestamp)))
332                   
[d9d68ba]333   
Note: See TracBrowser for help on using the repository browser.