source: sasview/sansview/setup_all.py @ 296b9c1

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 296b9c1 was 6367ec5, checked in by Jae Cho <jhjcho@…>, 13 years ago

build python/sansview package via source (for linux tar ball)

  • Property mode set to 100644
File size: 9.2 KB
Line 
1#
2# Script for linux to setup all SansView internal packages (Not on sansview itself)
3#
4# Usage:
5# python setup_all.py
6
7import os
8import sys
9import shutil
10import logging
11
12# Installation folder
13import time
14timestamp = int(time.time())
15CWD    = os.getcwd()
16
17# On Windows, the python executable is not always on the path.
18# Use its most frequent location as the default.
19if sys.platform == 'win32':
20    PYTHON = "c:\python25\python"
21   
22else:
23    PYTHON = 'python'
24
25
26# Release version 1.9
27SANSMODELS = "0.9.1"
28DATALOADER = "0.9"
29GUIFRAME   = "0.9.1"
30SANSVIEW   = "1.9.1"
31PLOTTOOLS  = "0.9.1"
32UTIL       = "0.9.1"
33PARK       = "1.2.1"
34PARK_INTEG = "0.9.1"
35PRVIEW     = "0.9.1"
36PR_INV     = "0.9"
37CALCULATOR = "0.9.1"
38CALC_VIEW  = "0.9"
39INVARIANT  = "0.9.1"
40INV_VIEW   = "0.9"
41FIT_VIEW   = "0.9.1"
42
43
44def check_system():
45    """
46        Checks that the system has the necessary modules.
47    """
48    is_ok = True
49    try:
50        import wx
51        if not wx.__version__.count('2.8.11') and \
52             not wx.__version__.count('2.8.12'):
53            print "wx: Recommending version 2.8.11 or 2.8.12"
54    except:
55        is_ok = False
56        print "Error: wxpython 2.8.11 (12) missing"
57        logging.error("wxpython missing")
58   
59    try:
60        import matplotlib
61        if not matplotlib.__version__.count('0.99.0') and \
62             not matplotlib.__version__.count('0.99.1'):
63            print "matplotlib: Recommending version 0.99.0 or 0.99.1"
64    except:
65        is_ok = False
66        print "Error: matplotlib 0.99.0 (1) missing"
67        logging.error("matplotlib missing")
68       
69    try:
70        import numpy 
71        if not numpy.__version__.count('1.4.1'):
72            print "numpy: Recommending version 1.4.1"
73    except:
74        is_ok = False
75        print "Error: numpy 1.4.1 missing"
76        logging.error("numpy missing")
77       
78    try:
79        import scipy 
80        if not scipy.__version__.count('0.7.2'):
81            print "scipy: Recommending version 0.7.2"
82    except:
83        is_ok = False
84        print "Error: scipy 0.7.2 missing"
85        logging.error("scipy missing")
86
87    try:
88        import periodictable
89        if not periodictable.__version__.count('1.3.0'):
90            print "periodictable: Recommending version 1.3.0"
91    except:
92        print "Trying to install perodic table..."
93        try:
94            os.system("easy_install periodictable")
95            print "installed periodictable"
96        except:
97            is_ok = False
98            print "easy_install periodictable failed"
99            logging.error("periodictable missing")
100   
101     
102    try:
103        if sys.platform.count("win32")> 0:
104            from wx.lib.pdfwin import PDFWindow   
105    except:
106        is_ok = False
107        print "comtypes missing"
108        logging.error("comtypes missing")
109       
110    try:
111        if sys.platform.count("win32")> 0:
112            import win32com
113    except:
114        is_ok = False
115        print "pywin32 missing"
116        logging.error("pywin32 missing")
117           
118    try:
119        import pyparsing
120    except:
121        try:
122            os.system("easy_install pyparsing")
123            print "installed pyparsing"
124        except:
125            is_ok = False
126            print "easy_install pyparsing failed"
127            logging.error("pyparsing missing")
128             
129    if os.system("gcc -dumpversion")==1:
130        is_ok = False
131        logging.error("missing mingw")
132   
133    return is_ok
134
135
136def install_pkg(setup_dir):
137    """
138        Check a package out and install it
139       
140        @param install_dir: directory to put the code in
141        @param setup_dir: relative location of the setup.py script
142        @param url: URL of the SVN repo
143    """
144    #print "PYTHON, LIB_FOLDER=====",PYTHON
145    #logging.info("Installing Pakages" )
146    try:   
147        os.chdir(setup_dir) 
148        os.system("%s setup.py install" % PYTHON)   
149    except:
150        logging.error("Install failed on %s"% setup_dir)
151        logging.error(sys.exc_value)
152        raw_input("Press enter to continue\n")
153        sys.exit()
154
155def install(release=False):
156    """
157        Check the SansView code out
158    """
159    wd = os.getcwd()
160    os.chdir(wd)
161   
162    if release:
163        install_pkg("sansdataloader-%s" % DATALOADER)
164    else:
165        install_pkg("sansdataloader")
166   
167    os.chdir(wd)
168    if release:
169        install_pkg("sansmodels-%s" % SANSMODELS)
170    else:
171        install_pkg("sansmodels")
172   
173    os.chdir(wd)
174    if release:
175        install_pkg("sansguiframe-%s" % GUIFRAME)
176    else:
177        install_pkg("sansguiframe")
178   
179    os.chdir(wd)
180    if release:
181        install_pkg("plottools-%s" % PLOTTOOLS)
182    else:
183        install_pkg("plottools")
184   
185    os.chdir(wd)
186    if release:
187        install_pkg("util-%s" % UTIL)
188    else:
189        install_pkg("util")
190   
191    os.chdir(wd)
192    if release:
193        install_pkg("park_integration-%s" % PARK_INTEG)
194    else:
195        install_pkg("park_integration")
196   
197    os.chdir(wd)
198    if release:
199        install_pkg("inversionview-%s" % PRVIEW)
200    else:
201        install_pkg("inversionview")
202   
203    os.chdir(wd)
204    if release:
205        install_pkg("pr_inversion-%s" % PR_INV)
206    else:
207        install_pkg("pr_inversion")
208   
209    os.chdir(wd)
210    if release:
211        install_pkg("sansinvariant-%s" % INVARIANT)
212    else:
213        install_pkg("sansinvariant")
214   
215    os.chdir(wd)
216    if release:
217        install_pkg("invariantview-%s" % INV_VIEW)
218    else:
219        install_pkg("invariantview")
220   
221    os.chdir(wd)
222    if release:
223        install_pkg("calculatorview-%s" % CALC_VIEW)
224    else:
225        install_pkg("calculatorview")
226   
227    os.chdir(wd)
228    if release:
229        install_pkg("sanscalculator-%s" % CALCULATOR)
230    else:
231        install_pkg("sanscalculator")
232
233
234    os.chdir(wd)
235    if release:
236        install_pkg("park-%s" % PARK)
237    else:
238        install_pkg("park-1.2")
239       
240    os.chdir(wd)
241    if release:
242        install_pkg("fittingview-%s" % FIT_VIEW)
243    else:
244        install_pkg("fittingview")
245           
246    os.chdir(wd)
247    if release:
248        setup_dir = "sansview-%s" % SANSVIEW
249    else:
250        setup_dir = "sansview" 
251       
252    # run sansview
253    try:
254        os.chdir(setup_dir) 
255        os.system("%s sansview.py" % PYTHON) 
256    except:
257        pass
258           
259    # try to make the sansview dir writable to everyone
260    os.chdir(wd) 
261    try:
262        os.system("chmod 777 -R %s"% setup_dir)
263    except:
264        print "Could not give a permission to everyone for %s." % setup_dir
265
266           
267def prepare(wipeout = True):
268    """
269        Prepare the build
270       
271        @param wipeout: If True, the DANSE modules in the standard site-packages will be
272        removed to avoid conflicts.
273    """
274    # Remove existing libraries
275    if wipeout == True:
276       
277        logging.info("Deleting DANSES modules in site-packages")
278        from distutils.sysconfig import get_python_lib
279        libdir = get_python_lib()
280        old_dirs = [os.path.join(libdir, 'danse'),
281                    os.path.join(libdir, 'data_util'),
282                    os.path.join(libdir, 'park'),
283                    os.path.join(libdir, 'sans'),
284                    ]
285        for d in old_dirs:
286            if os.path.isdir(d):
287                shutil.rmtree(d)
288                 
289       
290if __name__ == "__main__": 
291   
292    if check_system():   
293        if len(sys.argv)==1:
294            # If there is no argument, build the installer
295            sys.argv.append("-t")
296           
297        if len(sys.argv)>1:
298            # Help
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"       
306
307            elif sys.argv[1]=="-n":
308                # Print out release URLs
309                print SANSMODELS_URL
310                print DATALOADER_URL
311                print GUIFRAME_URL
312                print PLOTTOOLS_URL
313                print UTIL_URL
314                print SANSVIEW_URL
315                print PARK_INTEG_URL
316                print PARK_URL
317                print PRVIEW
318                print PR_INV
319                print FIT_URL
320            else:
321                logging.info("Build script for SansView %s" % SANSVIEW)
322                print "Warning: This script will delete the previous SansView packages..."
323                prepare()
324                # Check the command line argument
325                if sys.argv[1]=="-t":
326                    logging.info("Building from trunk version")
327                    install()
328                else:
329                    logging.info("Building from release version")
330                    install(True)
331   
332   
333
334        raw_input("Press enter to continue\n")
335   
336    else:
337        raw_input("Press enter and install the missing packages before re-run this scripts.\n")
Note: See TracBrowser for help on using the repository browser.