/[escript]/branches/4.0fordebian/site_scons/site_init.py
ViewVC logotype

Diff of /branches/4.0fordebian/site_scons/site_init.py

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

branches/domexper/site_scons/site_init.py revision 3251 by jfenwick, Thu Oct 7 04:02:30 2010 UTC trunk/site_scons/site_init.py revision 4576 by sshaw, Mon Dec 9 23:35:30 2013 UTC
# Line 1  Line 1 
1    
2  ########################################################  ##############################################################################
3  #  #
4  # Copyright (c) 2003-2010 by University of Queensland  # Copyright (c) 2003-2013 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-2010 by University of Queensland  __copyright__="""Copyright (c) 2003-2013 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    from SCons.Defaults import Chmod, Copy
25    from grouptest import *
26    
27  def findLibWithHeader(env, libs, header, paths, lang='c'):  def findLibWithHeader(env, libs, header, paths, lang='c++'):
28      from SCons.Script.SConscript import Configure      from SCons.Script.SConscript import Configure
29      inc_path=''      inc_path=''
30      lib_path=''      lib_path=''
# Line 69  def findLibWithHeader(env, libs, header, Line 72  def findLibWithHeader(env, libs, header,
72      conf.Finish()      conf.Finish()
73      return inc_path, lib_path      return inc_path, lib_path
74    
75    def detectModule(env, module):
76        from tempfile import TemporaryFile
77        p=subprocess.call([env['pythoncmd'],'-c','import %s'%module], stderr=TemporaryFile())
78        if p != 0:
79            env[module] = False
80            return False
81        env[module] = True
82        return True
83    
84    def write_buildvars(env):
85        buildvars=open(os.path.join(env['libinstall'], 'buildvars'), 'w')
86        for k,v in sorted(env['buildvars'].items()):
87            buildvars.write("%s=%s\n"%(k,v))
88        buildvars.close()
89    
90    def generateTestScripts(env, TestGroups):
91        try:
92            utest=open('utest.sh','w')
93            utest.write(GroupTest.makeHeader(env['PLATFORM'], env['prefix'], False))
94            for tests in TestGroups:
95                utest.write(tests.makeString())
96            utest.close()
97            env.Execute(Chmod('utest.sh', 0o755))
98            print("Generated utest.sh.")
99            # This version contains only python tests - I want this to be usable
100            # from a binary only install if you have the test files
101            utest=open('itest.sh','w')
102            utest.write(GroupTest.makeHeader(env['PLATFORM'], env['prefix'], True))
103            for tests in TestGroups:
104              if tests.exec_cmd=='$PYTHONRUNNER ':
105                utest.write(tests.makeString())
106            utest.close()
107            env.Execute(Chmod('itest.sh', 0o755))
108            print("Generated itest.sh.")        
109        except IOError:
110            env['warnings'].append("Error attempting to write unit test script(s).")
111    
112        # delete scripts upon cleanup
113        env.Clean('target_init', 'utest.sh')
114        env.Clean('target_init', 'itest.sh')
115    
116        # Make sure that the escript wrapper is in place
117        if not os.path.isfile(os.path.join(env['bininstall'], 'run-escript')):
118            print("Copying escript wrapper.")
119            env.Execute(Copy(os.path.join(env['bininstall'],'run-escript'), 'bin/run-escript'))
120    
121  # Code to build .pyc from .py  # Code to build .pyc from .py
122  def build_py(target, source, env):  def build_py(target, source, env):
123      py_compile.compile(str(source[0]), str(target[0]))      try:
124      return 0         py_compile.compile(str(source[0]), str(target[0]), doraise=True)
125           return 0
126        except py_compile.PyCompileError, e:
127           print e
128           return 1
129    
130    
131  # Code to run unit_test executables  # Code to run unit_test executables
132  def runUnitTest(target, source, env):  def runUnitTest(target, source, env):
# Line 80  def runUnitTest(target, source, env): Line 134  def runUnitTest(target, source, env):
134    app = str(source[0].abspath)    app = str(source[0].abspath)
135    pn, sn= os.path.split(app)    pn, sn= os.path.split(app)
136    if not os.name== "nt":    if not os.name== "nt":
137       app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -bv "+os.path.join('.',sn)       app = "cd "+pn+"; "+os.path.join(env['bininstall'], "run-escript")+" -bv "+os.path.join('.',sn)
138    else:    else:
139        if env['usempi']:        if env['usempi']:
140            app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\            app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
141              "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\              "FINLEY_TEST_DATA,PATH %s"\
142              %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)              %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)
143        else:        else:
144             app = "cd "+ pn +" & "+sn             app = "cd "+ pn +" & "+sn
# Line 100  def runPyUnitTest(target, source, env): Line 154  def runPyUnitTest(target, source, env):
154     time_start = time.time()     time_start = time.time()
155     app = str(source[0].abspath)     app = str(source[0].abspath)
156     pn, sn= os.path.split(app)     pn, sn= os.path.split(app)
157     if os.name== "nt":     if os.name=="nt":
158         if env['usempi']:         if env['usempi']:
159             app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\             app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
160                "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\                "FINLEY_TEST_DATA,PATH %s\pythonMPIredirect.exe %s"\
161                %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)                %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)
162         else:         else:
163             app = "cd "+ pn +" & "+sys.executable + " " + sn             app = "cd "+ pn +" & "+sys.executable + " " + sn
164     else:     else:
165       app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -ov "+sn       app = "cd "+pn+"; "+os.path.join(env['bininstall'], "run-escript")+" -ov "+sn
166     print "Executing test: ",app     print "Executing test: ",app
167     if env.Execute(app) == 0:     if env.Execute(app) == 0:
168        open(str(target[0]),'w').write("PASSED\n")        open(str(target[0]),'w').write("PASSED\n")
# Line 119  def runPyUnitTest(target, source, env): Line 173  def runPyUnitTest(target, source, env):
173    
174  def eps2pdf(target, source, env):  def eps2pdf(target, source, env):
175  #   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:
176     if env.Execute("ps2pdf "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:     if env.Execute("ps2pdf -dEPSCrop "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:
177         return 1         return 1
178     return None     return None
179    
180  def effectiveName(inname):  def effectiveName(inname):
181     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?
182     if m.match(inname):      if m.match(inname):
183      return "savanna"          return "savanna"
184     return inname      return inname

Legend:
Removed from v.3251  
changed lines
  Added in v.4576

  ViewVC Help
Powered by ViewVC 1.1.26