/[escript]/trunk/site_scons/site_init.py
ViewVC logotype

Diff of /trunk/site_scons/site_init.py

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

revision 4300 by caltinay, Mon Mar 11 00:50:19 2013 UTC revision 5017 by sshaw, Tue Jun 10 02:16:18 2014 UTC
# Line 1  Line 1 
1    
2  ##############################################################################  ##############################################################################
3  #  #
4  # Copyright (c) 2003-2013 by University of Queensland  # Copyright (c) 2003-2014 by University of Queensland
5  # http://www.uq.edu.au  # http://www.uq.edu.au
6  #  #
7  # Primary Business: Queensland, Australia  # Primary Business: Queensland, Australia
# Line 9  Line 9 
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)  # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12  # Development since 2012 by School of Earth Sciences  # Development 2012-2013 by School of Earth Sciences
13    # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14  #  #
15  ##############################################################################  ##############################################################################
16    
17  __copyright__="""Copyright (c) 2003-2013 by University of Queensland  __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18  http://www.uq.edu.au  http://www.uq.edu.au
19  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
20  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
# Line 21  http://www.opensource.org/licenses/osl-3 Line 22  http://www.opensource.org/licenses/osl-3
22  __url__="https://launchpad.net/escript-finley"  __url__="https://launchpad.net/escript-finley"
23    
24  import sys, os, time, py_compile, re, subprocess  import sys, os, time, py_compile, re, subprocess
25  from SCons.Defaults import Chmod  from SCons.Defaults import Chmod, Copy
26  from grouptest import *  from grouptest import *
27    
28  def findLibWithHeader(env, libs, header, paths, lang='c'):  def findLibWithHeader(env, libs, header, paths, lang='c++'):
29      from SCons.Script.SConscript import Configure      from SCons.Script.SConscript import Configure
30      inc_path=''      inc_path=''
31      lib_path=''      lib_path=''
# Line 73  def findLibWithHeader(env, libs, header, Line 74  def findLibWithHeader(env, libs, header,
74      return inc_path, lib_path      return inc_path, lib_path
75    
76  def detectModule(env, module):  def detectModule(env, module):
77      p=subprocess.call([env['pythoncmd'],'-c','import %s'%module])      from tempfile import TemporaryFile
78        p=subprocess.call([env['pythoncmd'],'-c','import %s'%module], stderr=TemporaryFile())
79      if p != 0:      if p != 0:
80          env[module] = False          env[module] = False
81          return False          return False
# Line 115  def generateTestScripts(env, TestGroups) Line 117  def generateTestScripts(env, TestGroups)
117      # Make sure that the escript wrapper is in place      # Make sure that the escript wrapper is in place
118      if not os.path.isfile(os.path.join(env['bininstall'], 'run-escript')):      if not os.path.isfile(os.path.join(env['bininstall'], 'run-escript')):
119          print("Copying escript wrapper.")          print("Copying escript wrapper.")
120          Execute(Copy(os.path.join(env['bininstall'],'run-escript'), 'bin/run-escript'))          env.Execute(Copy(os.path.join(env['bininstall'],'run-escript'), 'bin/run-escript'))
121    
122  # Code to build .pyc from .py  # Code to build .pyc from .py
123  def build_py(target, source, env):  def build_py(target, source, env):
# Line 137  def runUnitTest(target, source, env): Line 139  def runUnitTest(target, source, env):
139    else:    else:
140        if env['usempi']:        if env['usempi']:
141            app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\            app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
142              "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\              "FINLEY_TEST_DATA,PATH %s"\
143              %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)              %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)
144        else:        else:
145             app = "cd "+ pn +" & "+sn             app = "cd "+ pn +" & "+sn
# Line 149  def runUnitTest(target, source, env): Line 151  def runUnitTest(target, source, env):
151    print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)    print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)
152    return None    return None
153    
154    def binpath(env, name=None):
155        if not name:
156            return env['bininstall']
157        return os.path.join(env['bininstall'], name)
158    
159  def runPyUnitTest(target, source, env):  def runPyUnitTest(target, source, env):
160     time_start = time.time()     time_start = time.time()
161     app = str(source[0].abspath)     app = str(source[0].abspath)
162     pn, sn= os.path.split(app)     pn, sn= os.path.split(app)
163     if os.name== "nt":     if os.name=="nt":
164         if env['usempi']:         if env['usempi']:
165             app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\             app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
166                "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\                "FINLEY_TEST_DATA,PATH %s\pythonMPIredirect.exe %s"\
167                %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)                %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)
168         else:         else:
169             app = "cd "+ pn +" & "+sys.executable + " " + sn             app = "cd "+ pn +" & "+sys.executable + " " + sn
170     else:     else:
171       app = "cd "+pn+"; "+os.path.join(env['bininstall'], "run-escript")+" -ov "+sn      
172         app = "cd "+pn+"; "+binpath(env, "run-escript")+" -ov "+binpath(env,
173                "../tools/testrunner.py")+" -outputfile="+os.path.join(env['build_dir'],
174                sn[:-3])+".skipped "+sn
175       print "Executing test: ",app
176       if env.Execute(app) == 0:
177          open(str(target[0]),'w').write("PASSED\n")
178       else:
179         return 1
180       print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)
181       return None
182    
183    def runPyExample(target, source, env):
184       time_start = time.time()
185       app = str(source[0].abspath)
186       pn, sn= os.path.split(app)
187       if os.name=="nt":
188           if env['usempi']:
189               app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
190                  "FINLEY_TEST_DATA,PATH %s\pythonMPIredirect.exe %s"\
191                  %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)
192           else:
193               app = "cd "+ pn +" & "+sys.executable + " " + sn
194       else:
195        
196         app = "cd "+pn+"; pwd; "+binpath(env, "run-escript")+" -ov "+sn
197     print "Executing test: ",app     print "Executing test: ",app
198     if env.Execute(app) == 0:     if env.Execute(app) == 0:
199        open(str(target[0]),'w').write("PASSED\n")        open(str(target[0]),'w').write("PASSED\n")
# Line 173  def runPyUnitTest(target, source, env): Line 205  def runPyUnitTest(target, source, env):
205  def eps2pdf(target, source, env):  def eps2pdf(target, source, env):
206  #   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:
207     if env.Execute("ps2pdf -dEPSCrop "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:     if env.Execute("ps2pdf -dEPSCrop "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:
208         return 1         return 1
209     return None     return None
210    
211  def effectiveName(inname):  def effectiveName(inname):
212     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?
213     if m.match(inname):      if m.match(inname):
214      return "savanna"          return "savanna"
215     return inname      return inname

Legend:
Removed from v.4300  
changed lines
  Added in v.5017

  ViewVC Help
Powered by ViewVC 1.1.26