/[escript]/branches/postrelease-csirofixes/site_scons/site_init.py
ViewVC logotype

Diff of /branches/postrelease-csirofixes/site_scons/site_init.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/scons/scons_extensions.py revision 2423 by gross, Thu May 14 05:02:20 2009 UTC trunk/site_scons/site_init.py revision 3981 by jfenwick, Fri Sep 21 02:47:54 2012 UTC
# Line 1  Line 1 
1    
2  ########################################################  ##############################################################################
3  #  #
4  # Copyright (c) 2003-2008 by University of Queensland  # Copyright (c) 2003-2012 by University of Queensland
5  # Earth Systems Science Computational Center (ESSCC)  # http://www.uq.edu.au
 # http://www.uq.edu.au/esscc  
6  #  #
7  # Primary Business: Queensland, Australia  # Primary Business: Queensland, Australia
8  # Licensed under the Open Software License version 3.0  # Licensed under the Open Software License version 3.0
9  # http://www.opensource.org/licenses/osl-3.0.php  # http://www.opensource.org/licenses/osl-3.0.php
10  #  #
11  ########################################################  # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12    # Development since 2012 by School of Earth Sciences
13    #
14    ##############################################################################
15    
16  __copyright__="""Copyright (c) 2003-2008 by University of Queensland  __copyright__="""Copyright (c) 2003-2012 by University of Queensland
17  Earth Systems Science Computational Center (ESSCC)  http://www.uq.edu.au
 http://www.uq.edu.au/esscc  
18  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
19  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
20  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
21  __url__="https://launchpad.net/escript-finley"  __url__="https://launchpad.net/escript-finley"
22    
23  import sys, os, time, glob, fnmatch, types, py_compile, re  import sys, os, time, py_compile, re, subprocess
24    
25  from SCons.Script.SConscript import SConsEnvironment  def findLibWithHeader(env, libs, header, paths, lang='c'):
26        from SCons.Script.SConscript import Configure
27        inc_path=''
28        lib_path=''
29        # 'paths' may be a prefix, so look for lib and include subdirectories
30        if type(paths)==str:
31            # find the header file first
32            for i in 'include','include64','include32','inc':
33                inc=os.path.join(paths, i)
34                if os.path.isfile(os.path.join(inc, header)):
35                    inc_path=inc
36                    break
37            if inc_path=='':
38                raise RuntimeError('%s not found under %s'%(header,paths))
39    
40            # now try to find a lib directory
41            for l in 'lib','lib64','lib32':
42                lp=os.path.join(paths, l)
43                if os.path.isdir(lp):
44                    lib_path=lp
45                    break
46            if lib_path=='':
47                raise RuntimeError('No lib directory found under %s'%paths)
48        else:
49            if os.path.isfile(os.path.join(paths[0], header)):
50                inc_path=paths[0]
51            else:
52                raise RuntimeError('%s not found under %s'%(header,paths[0]))
53            if os.path.isdir(paths[1]):
54                lib_path=paths[1]
55            else:
56                raise RuntimeError('%s is not a valid path.'%paths[1])
57    
58        # now try the library
59        conf=Configure(env.Clone())
60        conf.env.AppendUnique(CPPPATH = [inc_path])
61        conf.env.AppendUnique(LIBPATH = [lib_path])
62        if type(libs)==str: libs=[libs]
63        # we can't check for each library by itself since they may depend on each
64        # other, so we add all libraries to the link line and check only for one
65        conf.env.AppendUnique(LIBS = libs)
66        if not conf.CheckLibWithHeader(libs[0], header, lang):
67            conf.Finish()
68            raise RuntimeError('Unable to link against %s (paths: %s, %s)'%(libs,inc_path,lib_path))
69    
70        conf.Finish()
71        return inc_path, lib_path
72    
73    def detectModule(env, module):
74        if env['pythoncmd']=='python':
75            try:
76                __import__(module)
77            except ImportError:
78                return False
79        else:
80            p=subprocess.call([env['pythoncmd'],'-c','import %s'%module])
81            if p!=0:
82                return False
83        return True
84    
85  # Code to build .pyc from .py  # Code to build .pyc from .py
86  def build_py(target, source, env):  def build_py(target, source, env):
87      py_compile.compile(str(source[0]), str(target[0]))      try:
88      return 0         py_compile.compile(str(source[0]), str(target[0]), doraise=True)
89           return 0
90        except py_compile.PyCompileError, e:
91           print e
92           return 1
93          
94    
95  # Code to run unit_test executables  # Code to run unit_test executables
96  def runUnitTest(target, source, env):  def runUnitTest(target, source, env):
97    time_start = time.time()    time_start = time.time()
98    app = str(source[0].abspath)    app = str(source[0].abspath)
99      pn, sn= os.path.split(app)
100    if not os.name== "nt":    if not os.name== "nt":
101       app = os.path.join(env['bininstall'],"escript")+" -bv "+app       app = "cd "+pn+"; "+os.path.join(env['bininstall'], "run-escript")+" -bv "+os.path.join('.',sn)
102    else:    else:
103        if env['usempi']:        if env['usempi']:
104            app = "mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\            app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
105              "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\              "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\
106              %(env['ENV']['ESCRIPT_NUM_NODES'], app)              %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)
107          else:
108               app = "cd "+ pn +" & "+sn
109    print "Executing test: " + app    print "Executing test: " + app
110    if not env.Execute(app):    if not env.Execute(app):
111      open(str(target[0]),'w').write("PASSED\n")      open(str(target[0]),'w').write("PASSED\n")
# Line 50  def runUnitTest(target, source, env): Line 117  def runUnitTest(target, source, env):
117  def runPyUnitTest(target, source, env):  def runPyUnitTest(target, source, env):
118     time_start = time.time()     time_start = time.time()
119     app = str(source[0].abspath)     app = str(source[0].abspath)
120       pn, sn= os.path.split(app)
121     if os.name== "nt":     if os.name== "nt":
122         if env['usempi']:         if env['usempi']:
123             app = "mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\             app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
124                "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\                "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\
125                %(env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],app)                %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)
126         else:         else:
127             app = sys.executable + " " + app             app = "cd "+ pn +" & "+sys.executable + " " + sn
128     else:     else:
129       app = os.path.join(env['bininstall'],"escript")+" -ov "+app       app = "cd "+pn+"; "+os.path.join(env['bininstall'], "run-escript")+" -ov "+sn
130     print "Executing test: " + app     print "Executing test: ",app
131     if env.Execute(app) == 0:     if env.Execute(app) == 0:
132        open(str(target[0]),'w').write("PASSED\n")        open(str(target[0]),'w').write("PASSED\n")
133     else:     else:
# Line 68  def runPyUnitTest(target, source, env): Line 136  def runPyUnitTest(target, source, env):
136     return None     return None
137    
138  def eps2pdf(target, source, env):  def eps2pdf(target, source, env):
139     if env.Execute("epstopdf "+str(source[0].abspath)+" -o "+str(target[0].abspath))!=0:  #   if env.Execute("epstopdf "+str(source[0].abspath)+" -o "+str(target[0].abspath))!=0:
140       if env.Execute("ps2pdf -dEPSCrop "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:
141         return 1         return 1
142     return None     return None
143    
144  def effectiveName(inname):  def effectiveName(inname):
145     m=re.compile("^r1i[0-9]{1,2}n[0-9]{1,2}$")   # savanna names take the form r1i?n?     m=re.compile("^r1i[0-9]{1,2}n[0-9]{1,2}$")   # savanna names take the form r1i?n?
146     if m.match(inname):     if m.match(inname):
147      return "service0"      return "savanna"
148     return inname     return inname

Legend:
Removed from v.2423  
changed lines
  Added in v.3981

  ViewVC Help
Powered by ViewVC 1.1.26