source: sasview/sansview/build_sansview.py @ 8e2a888

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 8e2a888 was 4356634, checked in by Jae Cho <jhjcho@…>, 14 years ago

preparing bug-fix release

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