source: sasview/sansview/build_sansview.py @ 90e5ca1

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 90e5ca1 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
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   
[40f9745]185    #TODO: need a release version of PARK
186    os.chdir(wd)
187    if release:
[249bae9]188        install_pkg(".", "park-1.2", PARK_URL)
[40f9745]189    else:
190        install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2")
191   
192    os.chdir(wd)
193    if release:
[7b35808]194        os.system("%s checkout -q %s" % (SVN, SANSVIEW_URL))
[40f9745]195    else:
[7b35808]196        os.system("%s checkout -q svn://danse.us/sans/trunk/sansview" % SVN)
[40f9745]197   
[b81cf5c]198def prepare(wipeout = False):
[7b35808]199    """
200        Prepare the build
201    """
202    # Remove existing libraries
[b81cf5c]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       
[7b35808]218    # Create a fresh installation folder
[40f9745]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
[531a811c]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    """
[b81cf5c]235    print "WARNING!\n"
[531a811c]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"
[b81cf5c]245    answer = raw_input("Do you want to delete those modules [Y] or continue with a dirty installation [N]? [Y|N]")
[531a811c]246    return answer.upper()=="Y"
247       
[40f9745]248if __name__ == "__main__": 
[6e2fe95]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       
[40f9745]255    if len(sys.argv)>1:
[6e2fe95]256        # Help
[40f9745]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"
[138ac69]264            print "    -i: Builds an installer from the release version [Windows only]"       
[249bae9]265            print "    -n: Print out the dependencies for the release notes"
[fa523d3]266        elif sys.argv[1]=="-n":
[6e2fe95]267            # Print out release URLs
[249bae9]268            print SANSMODELS_URL
269            print DATALOADER_URL
270            print GUICOMM_URL
271            print GUIFRAME_URL
272            print PLOTTOOLS_URL
273            print UTIL_URL
[fa523d3]274            print SANSVIEW_URL
[cd40805]275            print PARK_INTEG_URL
[249bae9]276            print PARK_URL
[b81af72]277            print PRVIEW
278            print PR_INV
[40f9745]279        else:
[7b35808]280            logging.info("Build script for SansView %s" % SANSVIEW)
[b81cf5c]281                   
[40f9745]282            # Prepare installation folder
[b81cf5c]283            prepare(warning())
[40f9745]284           
285            # Check the command line argument
286            if sys.argv[1]=="-t":
[7b35808]287                logging.info("Building trunk version")
[40f9745]288                checkout()
289            elif sys.argv[1]=="-r":
[7b35808]290                logging.info("Building release version")
[40f9745]291                checkout(True)
292            elif sys.argv[1]=="-i":
[7b35808]293                logging.info("Building release version")
[40f9745]294                checkout(True)
[138ac69]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                   
[d9d68ba]303   
Note: See TracBrowser for help on using the repository browser.