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

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 6f2c919 was b81cf5c, checked in by Mathieu Doucet <doucetm@…>, 15 years ago

sansview: modified builder

  • Property mode set to 100644
File size: 9.2 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   
[b81cf5c]179def prepare(wipeout = False):
[7b35808]180    """
181        Prepare the build
182    """
183    # Remove existing libraries
[b81cf5c]184    if wipeout == True:
185        print "Deleting old modules"
186        from distutils.sysconfig import get_python_lib
187        libdir = get_python_lib()
188        old_dirs = [os.path.join(libdir, 'danse'),
189                    os.path.join(libdir, 'data_util'),
190                    os.path.join(libdir, 'DataLoader'),
191                    os.path.join(libdir, 'park'),
192                    os.path.join(libdir, 'sans'),
193                    os.path.join(libdir, 'sans_extension'),
194                    ]
195        for d in old_dirs:
196            if os.path.isdir(d):
197                shutil.rmtree(d)
198       
[7b35808]199    # Create a fresh installation folder
[40f9745]200    if os.path.isdir(INSTALL_FOLDER):
201        shutil.rmtree(INSTALL_FOLDER)
202
203    os.mkdir(INSTALL_FOLDER)
204   
205    # Check that the dependencies are properly installed
206    check_system()   
207   
208    # Move to the installation folder
209    os.chdir(INSTALL_FOLDER)   
210
[531a811c]211def warning():
212    """
213        The build script will wipe out part of the site-packages.
214        Ask the user whether he wants to proceed.
215    """
[b81cf5c]216    print "WARNING!\n"
[531a811c]217    print "In order to build a clean version of SansView, this script"
218    print "deletes anything found under site-packages for the following"
219    print "modules:"
220    print "   - danse"
221    print "   - data_util"
222    print "   - DataLoader"
223    print "   - park"
224    print "   - sans"
225    print "   - sans_extension\n"
[b81cf5c]226    answer = raw_input("Do you want to delete those modules [Y] or continue with a dirty installation [N]? [Y|N]")
[531a811c]227    return answer.upper()=="Y"
228       
[40f9745]229if __name__ == "__main__": 
[6e2fe95]230    print "Build script for SansView %s" % SANSVIEW
231   
232    if len(sys.argv)==1:
233        # If there is no argument, build the installer
234        sys.argv.append("-i")
235       
[40f9745]236    if len(sys.argv)>1:
[6e2fe95]237        # Help
[40f9745]238        if sys.argv[1]=="-h":
239            print "Usage:"
240            print "    python build_sansview [command]\n"
241            print "[command] can be any of the following:"
242            print "    -h: lists the command line options"
243            print "    -r: Builds a SansView using the released modules"
244            print "    -t: Builds SansView from the trunk"
[138ac69]245            print "    -i: Builds an installer from the release version [Windows only]"       
[249bae9]246            print "    -n: Print out the dependencies for the release notes"
[fa523d3]247        elif sys.argv[1]=="-n":
[6e2fe95]248            # Print out release URLs
[249bae9]249            print SANSMODELS_URL
250            print DATALOADER_URL
251            print GUICOMM_URL
252            print GUIFRAME_URL
253            print PLOTTOOLS_URL
254            print UTIL_URL
[fa523d3]255            print SANSVIEW_URL
[cd40805]256            print PARK_INTEG_URL
[249bae9]257            print PARK_URL
[40f9745]258        else:
[7b35808]259            logging.info("Build script for SansView %s" % SANSVIEW)
[b81cf5c]260                   
[40f9745]261            # Prepare installation folder
[b81cf5c]262            prepare(warning())
[40f9745]263           
264            # Check the command line argument
265            if sys.argv[1]=="-t":
[7b35808]266                logging.info("Building trunk version")
[40f9745]267                checkout()
268            elif sys.argv[1]=="-r":
[7b35808]269                logging.info("Building release version")
[40f9745]270                checkout(True)
271            elif sys.argv[1]=="-i":
[7b35808]272                logging.info("Building release version")
[40f9745]273                checkout(True)
[138ac69]274                if sys.platform=='win32':
275                    logging.info("Building installer from release version")
276                    os.chdir("sansview-%s" % (SANSVIEW))
277                    os.system("%s setup_exe.py -q py2exe" % PYTHON)
278                    os.system("%s/Q installer.iss" % INNO)
279                    shutil.copy2(os.path.join("Output","setupSansView.exe"), 
280                                 os.path.join(CWD, "setupSansView_%s.exe" % str(timestamp)))
281                   
[d9d68ba]282   
Note: See TracBrowser for help on using the repository browser.