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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3212 - (hide annotations)
Tue Sep 28 01:06:07 2010 UTC (8 years, 8 months ago) by caltinay
Original Path: branches/scons_revamp_from_3210/site_scons/site_init.py
File MIME type: text/x-python
File size: 4699 byte(s)
First iteration:
- cleanup of main SConstruct file
- new template options file with commented options
- moved our extensions to the "proper" place according to scons docs
- fixed a regex issue in wrapper script
- this version works on guineapig and shake75

1 ksteube 1810
2     ########################################################
3     #
4 jfenwick 2881 # Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1810 # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7     #
8     # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11     #
12     ########################################################
13    
14 jfenwick 2881 __copyright__="""Copyright (c) 2003-2010 by University of Queensland
15 ksteube 1810 Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
21 ksteube 1810
22 jfenwick 2388 import sys, os, time, glob, fnmatch, types, py_compile, re
23 elspeth 645
24 phornby 1233 from SCons.Script.SConscript import SConsEnvironment
25    
26 caltinay 3212 def findLibWithHeader(env, libs, header, paths, lang='c'):
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)
60     conf.env.AppendUnique(CPPPATH = [inc_path])
61     conf.env.AppendUnique(LIBPATH = [lib_path])
62     if type(libs)==str: libs=[libs]
63     for lib in libs:
64     if not conf.CheckLibWithHeader(lib, header, lang):
65     conf.Finish()
66     raise RuntimeError('%s not found in %s, %s'%(lib,inc_path,lib_path))
67    
68     conf.Finish()
69     return inc_path, lib_path
70    
71 jgs 268 # Code to build .pyc from .py
72     def build_py(target, source, env):
73 phornby 1233 py_compile.compile(str(source[0]), str(target[0]))
74     return 0
75 jgs 297
76     # Code to run unit_test executables
77     def runUnitTest(target, source, env):
78 ksteube 1312 time_start = time.time()
79     app = str(source[0].abspath)
80 gross 2502 pn, sn= os.path.split(app)
81 gross 2363 if not os.name== "nt":
82 jfenwick 2506 app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -bv "+os.path.join('.',sn)
83 gross 2416 else:
84     if env['usempi']:
85 trankine 2629 app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
86 gross 2423 "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\
87 gross 2502 %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)
88     else:
89 trankine 2629 app = "cd "+ pn +" & "+sn
90 ksteube 1312 print "Executing test: " + app
91     if not env.Execute(app):
92 jgs 297 open(str(target[0]),'w').write("PASSED\n")
93 ksteube 1312 else:
94     return 1
95     print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)
96     return None
97 cochrane 370
98 robwdcock 682 def runPyUnitTest(target, source, env):
99 ksteube 1312 time_start = time.time()
100     app = str(source[0].abspath)
101 gross 2502 pn, sn= os.path.split(app)
102 gross 2363 if os.name== "nt":
103 gross 2416 if env['usempi']:
104 trankine 2629 app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
105 gross 2423 "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\
106 gross 2502 %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)
107 gross 2416 else:
108 trankine 2629 app = "cd "+ pn +" & "+sys.executable + " " + sn
109 ksteube 1312 else:
110 gross 2502 app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -ov "+sn
111     print "Executing test: ",app
112 gross 1374 if env.Execute(app) == 0:
113 ksteube 1312 open(str(target[0]),'w').write("PASSED\n")
114     else:
115     return 1
116     print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)
117     return None
118 phornby 1233
119 jfenwick 2387 def eps2pdf(target, source, env):
120 jfenwick 3053 # if env.Execute("epstopdf "+str(source[0].abspath)+" -o "+str(target[0].abspath))!=0:
121     if env.Execute("ps2pdf "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:
122 jfenwick 2387 return 1
123 jfenwick 2388 return None
124    
125     def effectiveName(inname):
126     m=re.compile("^r1i[0-9]{1,2}n[0-9]{1,2}$") # savanna names take the form r1i?n?
127     if m.match(inname):
128 jfenwick 3047 return "savanna"
129 jfenwick 2388 return inname

  ViewVC Help
Powered by ViewVC 1.1.26