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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3214 - (hide annotations)
Tue Sep 28 03:26:24 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: 5092 byte(s)
Builds on savanna now.

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 caltinay 3212 def findLibWithHeader(env, libs, header, paths, lang='c'):
25 caltinay 3214 from SCons.Script.SConscript import Configure
26 caltinay 3212 inc_path=''
27     lib_path=''
28     # 'paths' may be a prefix, so look for lib and include subdirectories
29     if type(paths)==str:
30     # find the header file first
31     for i in 'include','include64','include32','inc':
32     inc=os.path.join(paths, i)
33     if os.path.isfile(os.path.join(inc, header)):
34     inc_path=inc
35     break
36     if inc_path=='':
37     raise RuntimeError('%s not found under %s'%(header,paths))
38    
39     # now try to find a lib directory
40     for l in 'lib','lib64','lib32':
41     lp=os.path.join(paths, l)
42     if os.path.isdir(lp):
43     lib_path=lp
44     break
45     if lib_path=='':
46     raise RuntimeError('No lib directory found under %s'%paths)
47     else:
48     if os.path.isfile(os.path.join(paths[0], header)):
49     inc_path=paths[0]
50     else:
51     raise RuntimeError('%s not found under %s'%(header,paths[0]))
52     if os.path.isdir(paths[1]):
53     lib_path=paths[1]
54     else:
55     raise RuntimeError('%s is not a valid path.'%paths[1])
56    
57     # now try the library
58 caltinay 3214 conf=Configure(clone_env(env))
59 caltinay 3212 conf.env.AppendUnique(CPPPATH = [inc_path])
60     conf.env.AppendUnique(LIBPATH = [lib_path])
61     if type(libs)==str: libs=[libs]
62 caltinay 3214 # we can't check for each library by itself since they may depend on each
63     # other, so we add all libraries to the link line and check only for one
64     conf.env.AppendUnique(LIBS = libs)
65     if not conf.CheckLibWithHeader(libs[0], header, lang):
66     conf.Finish()
67     raise RuntimeError('Unable to link against %s (paths: %s, %s)'%(libs,inc_path,lib_path))
68 caltinay 3212
69     conf.Finish()
70     return inc_path, lib_path
71    
72 caltinay 3214 # Make a copy of an environment
73     # scons <= 0.98: env.Copy()
74     # scons > 0.98: env.Clone()
75     def clone_env(env):
76     if 'Clone' in dir(env):
77     return env.Clone()
78     else:
79     return env.Copy()
80    
81 jgs 268 # Code to build .pyc from .py
82     def build_py(target, source, env):
83 phornby 1233 py_compile.compile(str(source[0]), str(target[0]))
84     return 0
85 jgs 297
86     # Code to run unit_test executables
87     def runUnitTest(target, source, env):
88 ksteube 1312 time_start = time.time()
89     app = str(source[0].abspath)
90 gross 2502 pn, sn= os.path.split(app)
91 gross 2363 if not os.name== "nt":
92 jfenwick 2506 app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -bv "+os.path.join('.',sn)
93 gross 2416 else:
94     if env['usempi']:
95 trankine 2629 app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
96 gross 2423 "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\
97 gross 2502 %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)
98     else:
99 trankine 2629 app = "cd "+ pn +" & "+sn
100 ksteube 1312 print "Executing test: " + app
101     if not env.Execute(app):
102 jgs 297 open(str(target[0]),'w').write("PASSED\n")
103 ksteube 1312 else:
104     return 1
105     print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)
106     return None
107 cochrane 370
108 robwdcock 682 def runPyUnitTest(target, source, env):
109 ksteube 1312 time_start = time.time()
110     app = str(source[0].abspath)
111 gross 2502 pn, sn= os.path.split(app)
112 gross 2363 if os.name== "nt":
113 gross 2416 if env['usempi']:
114 trankine 2629 app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
115 gross 2423 "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\
116 gross 2502 %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)
117 gross 2416 else:
118 trankine 2629 app = "cd "+ pn +" & "+sys.executable + " " + sn
119 ksteube 1312 else:
120 gross 2502 app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -ov "+sn
121     print "Executing test: ",app
122 gross 1374 if env.Execute(app) == 0:
123 ksteube 1312 open(str(target[0]),'w').write("PASSED\n")
124     else:
125     return 1
126     print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)
127     return None
128 phornby 1233
129 jfenwick 2387 def eps2pdf(target, source, env):
130 jfenwick 3053 # if env.Execute("epstopdf "+str(source[0].abspath)+" -o "+str(target[0].abspath))!=0:
131     if env.Execute("ps2pdf "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:
132 jfenwick 2387 return 1
133 jfenwick 2388 return None
134    
135     def effectiveName(inname):
136     m=re.compile("^r1i[0-9]{1,2}n[0-9]{1,2}$") # savanna names take the form r1i?n?
137     if m.match(inname):
138 jfenwick 3047 return "savanna"
139 jfenwick 2388 return inname

  ViewVC Help
Powered by ViewVC 1.1.26