source: sasview/sansview/build_sansview.py @ e5c6fff

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 e5c6fff was 138ac69, checked in by Mathieu Doucet <doucetm@…>, 15 years ago

sansview: modify build script to default to simple checkout of the release version on non-windows platforms.

  • Property mode set to 100644
File size: 9.1 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# Make sure svn.exe in on the path. You might need to log out and log back in again after installing SVN.
9#
10# Inno Setup must be installed
11#
12# py2exe must be installed
13#
[249bae9]14# mingw must be installed
15#
[40f9745]16# Usage:
17# python build_sansview [command]
18# [command] can be any of the following:
19#   -h: lists the command line options
20#   -r: Builds a SansView using the released modules.
21#   -t: Builds SansView from the trunk.
22#   -i: Builds an installer from the release version.
[249bae9]23#   -n: Print out the dependencies for the release notes
[40f9745]24
25import os
[138ac69]26import sys
[40f9745]27import shutil
[7b35808]28import logging
[40f9745]29
[7b35808]30# Installation folder
31import time
32timestamp = int(time.time())
33INSTALL_FOLDER = "install_%s" % str(timestamp)
34
35logging.basicConfig(level=logging.INFO,
36                    format='%(asctime)s %(levelname)s %(message)s',
37                    filename='build_%s.log' % str(timestamp),
38                    filemode='w')
39
40CWD    = os.getcwd()
[138ac69]41
42# On Windows, the python executable is not always on the path.
43# Use its most frequent location as the default.
44if sys.platform == 'win32':
45    PYTHON = "c:\python25\python"
46else:
47    PYTHON = 'python'
48
[40f9745]49SVN    = "svn"
50INNO   = "\"c:\Program Files\Inno Setup 5\ISCC\""
51
[531a811c]52# Release version 0.9.1
[b4390744]53SANSMODELS = "0.4.4"
[d9d68ba]54DATALOADER = "0.2.3"
55GUICOMM    = "0.1.2"
[b4390744]56GUIFRAME   = "0.1.6"
57SANSVIEW   = "0.9.1"
58PLOTTOOLS  = "0.1.5"
[d9d68ba]59UTIL       = "0.1.1"
60PARK       = "1.2"
[b4390744]61PARK_INTEG = "0.1.2"
[249bae9]62
[7b35808]63# URLs for SVN repos
[249bae9]64SANSMODELS_URL = "svn://danse.us/sans/releases/sansmodels-%s" % SANSMODELS
65DATALOADER_URL = "svn://danse.us/sans/releases/DataLoader-%s" % DATALOADER
66GUICOMM_URL = "svn://danse.us/sans/releases/guicomm-%s" % GUICOMM
67GUIFRAME_URL = "svn://danse.us/sans/releases/guiframe-%s" % GUIFRAME
68PLOTTOOLS_URL = "svn://danse.us/common/releases/plottools-%s/trunk" % PLOTTOOLS
69UTIL_URL = "svn://danse.us/common/releases/util-%s" % UTIL
70SANSVIEW_URL = "svn://danse.us/sans/releases/sansview-%s" % SANSVIEW
[fa523d3]71PARK_INTEG_URL = "svn://danse.us/sans/releases/park_integration-%s" % PARK_INTEG
[d9d68ba]72PARK_URL = "svn://danse.us/park/releases/park-%s" % PARK
[40f9745]73
74
75def check_system():
76    """
77        Checks that the system has the necessary modules.
78    """
79    try:
80        import wx
81    except:
[7b35808]82        logging.error("wxpython missing")
[40f9745]83   
84    try:
85        import matplotlib
86    except:
[7b35808]87        logging.error("matplotlib missing")
[40f9745]88       
89    try:
90        import numpy
91    except:
[7b35808]92        logging.error("numpy missing")
[40f9745]93       
94    try:
95        import scipy
96    except:
[7b35808]97        logging.error("scipy missing")
[40f9745]98       
99    if os.system("gcc -dumpversion")==1:
[7b35808]100        logging.error("missing mingw")
[40f9745]101
102def install_pkg(install_dir, setup_dir, url):
103    """
104        Check a package out and install it
105       
106        @param install_dir: directory to put the code in
107        @param setup_dir: relative location of the setup.py script
108        @param url: URL of the SVN repo
109    """
110    if not os.path.isdir(install_dir):
111        os.mkdir(install_dir)
112    os.chdir(install_dir)   
113    os.system("%s checkout -q %s" % (SVN, url))       
114    os.chdir(setup_dir)
[7b35808]115    os.system("%s setup.py -q build -cmingw32" % PYTHON)
116    os.system("%s setup.py -q install" % PYTHON)
[40f9745]117   
118def checkout(release=False):
119    """
120        Check the SansView code out
121    """
122    wd = os.getcwd()
123   
124    os.chdir(wd)
125    if release:
[249bae9]126        install_pkg(".", "sansmodels-%s/src" % SANSMODELS, SANSMODELS_URL)
[40f9745]127    else:
128        install_pkg(".", "sansmodels/src", "svn://danse.us/sans/trunk/sansmodels")
129   
130    os.chdir(wd)
131    if release:
[249bae9]132        install_pkg(".", "DataLoader-%s" % DATALOADER, DATALOADER_URL)
[40f9745]133    else:
134        install_pkg(".", "DataLoader", "svn://danse.us/sans/trunk/DataLoader")
135   
136    os.chdir(wd)
137    if release:
[249bae9]138        install_pkg(".", "guicomm-%s" % GUICOMM, GUICOMM_URL)
[40f9745]139    else:
140        install_pkg(".", "guicomm", "svn://danse.us/sans/trunk/guicomm")
141   
142    os.chdir(wd)
143    if release:
[249bae9]144        install_pkg(".", "guiframe-%s" % GUIFRAME, GUIFRAME_URL)
[40f9745]145    else:
146        install_pkg(".", "guiframe", "svn://danse.us/sans/trunk/guiframe")
147   
148    os.chdir(wd)
149    if release:
[249bae9]150        install_pkg("plottools-%s" % PLOTTOOLS, "trunk", PLOTTOOLS_URL)
[40f9745]151    else:
152        install_pkg("plottools", "trunk", "svn://danse.us/common/plottools/trunk")
153   
154    os.chdir(wd)
155    if release:
[249bae9]156        install_pkg(".", "util-%s" % UTIL, UTIL_URL)
[40f9745]157    else:
158        install_pkg(".", "util", "svn://danse.us/common/util")
159   
[fa523d3]160    os.chdir(wd)
161    if release:
162        install_pkg(".", "park_integration-%s" % PARK_INTEG, PARK_INTEG_URL)
163    else:
164        install_pkg(".", "park_integration", "svn://danse.us/sans/trunk/park_integration")
165   
[40f9745]166    #TODO: need a release version of PARK
167    os.chdir(wd)
168    if release:
[249bae9]169        install_pkg(".", "park-1.2", PARK_URL)
[40f9745]170    else:
171        install_pkg(".", "park-1.2", "svn://danse.us/park/branches/park-1.2")
172   
173    os.chdir(wd)
174    if release:
[7b35808]175        os.system("%s checkout -q %s" % (SVN, SANSVIEW_URL))
[40f9745]176    else:
[7b35808]177        os.system("%s checkout -q svn://danse.us/sans/trunk/sansview" % SVN)
[40f9745]178   
179def prepare():
[7b35808]180    """
181        Prepare the build
182    """
183    # Remove existing libraries
184    from distutils.sysconfig import get_python_lib
185    libdir = get_python_lib()
186    old_dirs = [os.path.join(libdir, 'danse'),
187                os.path.join(libdir, 'data_util'),
188                os.path.join(libdir, 'DataLoader'),
189                os.path.join(libdir, 'park'),
190                os.path.join(libdir, 'sans'),
191                os.path.join(libdir, 'sans_extension'),
192                ]
193    for d in old_dirs:
194        if os.path.isdir(d):
195            shutil.rmtree(d)
[40f9745]196   
[7b35808]197    # Create a fresh installation folder
[40f9745]198    if os.path.isdir(INSTALL_FOLDER):
199        shutil.rmtree(INSTALL_FOLDER)
200
201    os.mkdir(INSTALL_FOLDER)
202   
203    # Check that the dependencies are properly installed
204    check_system()   
205   
206    # Move to the installation folder
207    os.chdir(INSTALL_FOLDER)   
208
[531a811c]209def warning():
210    """
211        The build script will wipe out part of the site-packages.
212        Ask the user whether he wants to proceed.
213    """
214    print "WARNING!n"
215    print "In order to build a clean version of SansView, this script"
216    print "deletes anything found under site-packages for the following"
217    print "modules:"
218    print "   - danse"
219    print "   - data_util"
220    print "   - DataLoader"
221    print "   - park"
222    print "   - sans"
223    print "   - sans_extension\n"
224    answer = raw_input("Are you sure you want to proceed? [Y|N]")
225    return answer.upper()=="Y"
226       
[40f9745]227if __name__ == "__main__": 
[6e2fe95]228    print "Build script for SansView %s" % SANSVIEW
229   
[531a811c]230    # Make sure the user really wants to proceed
231    if not warning():
232        print "Execution canceled" 
233        sys.exit()
234   
[6e2fe95]235    if len(sys.argv)==1:
236        # If there is no argument, build the installer
237        sys.argv.append("-i")
238       
[40f9745]239    if len(sys.argv)>1:
[6e2fe95]240        # Help
[40f9745]241        if sys.argv[1]=="-h":
242            print "Usage:"
243            print "    python build_sansview [command]\n"
244            print "[command] can be any of the following:"
245            print "    -h: lists the command line options"
246            print "    -r: Builds a SansView using the released modules"
247            print "    -t: Builds SansView from the trunk"
[138ac69]248            print "    -i: Builds an installer from the release version [Windows only]"       
[249bae9]249            print "    -n: Print out the dependencies for the release notes"
[fa523d3]250        elif sys.argv[1]=="-n":
[6e2fe95]251            # Print out release URLs
[249bae9]252            print SANSMODELS_URL
253            print DATALOADER_URL
254            print GUICOMM_URL
255            print GUIFRAME_URL
256            print PLOTTOOLS_URL
257            print UTIL_URL
[fa523d3]258            print SANSVIEW_URL
[cd40805]259            print PARK_INTEG_URL
[249bae9]260            print PARK_URL
[40f9745]261        else:
[7b35808]262            logging.info("Build script for SansView %s" % SANSVIEW)
[40f9745]263            # Prepare installation folder
264            prepare()
265           
266            # Check the command line argument
267            if sys.argv[1]=="-t":
[7b35808]268                logging.info("Building trunk version")
[40f9745]269                checkout()
270            elif sys.argv[1]=="-r":
[7b35808]271                logging.info("Building release version")
[40f9745]272                checkout(True)
273            elif sys.argv[1]=="-i":
[7b35808]274                logging.info("Building release version")
[40f9745]275                checkout(True)
[138ac69]276                if sys.platform=='win32':
277                    logging.info("Building installer from release version")
278                    os.chdir("sansview-%s" % (SANSVIEW))
279                    os.system("%s setup_exe.py -q py2exe" % PYTHON)
280                    os.system("%s/Q installer.iss" % INNO)
281                    shutil.copy2(os.path.join("Output","setupSansView.exe"), 
282                                 os.path.join(CWD, "setupSansView_%s.exe" % str(timestamp)))
283                   
[d9d68ba]284   
Note: See TracBrowser for help on using the repository browser.