/[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 3981 - (hide annotations)
Fri Sep 21 02:47:54 2012 UTC (6 years, 8 months ago) by jfenwick
Original Path: trunk/site_scons/site_init.py
File MIME type: text/x-python
File size: 5371 byte(s)
First pass of updating copyright notices
1 ksteube 1810
2 jfenwick 3981 ##############################################################################
3 ksteube 1810 #
4 jfenwick 3911 # Copyright (c) 2003-2012 by University of Queensland
5 jfenwick 3981 # http://www.uq.edu.au
6 ksteube 1810 #
7     # Primary Business: Queensland, Australia
8     # Licensed under the Open Software License version 3.0
9     # http://www.opensource.org/licenses/osl-3.0.php
10     #
11 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12     # Development since 2012 by School of Earth Sciences
13     #
14     ##############################################################################
15 ksteube 1810
16 jfenwick 3911 __copyright__="""Copyright (c) 2003-2012 by University of Queensland
17 jfenwick 3981 http://www.uq.edu.au
18 ksteube 1810 Primary Business: Queensland, Australia"""
19     __license__="""Licensed under the Open Software License version 3.0
20     http://www.opensource.org/licenses/osl-3.0.php"""
21 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
22 ksteube 1810
23 caltinay 3975 import sys, os, time, py_compile, re, subprocess
24 elspeth 645
25 caltinay 3212 def findLibWithHeader(env, libs, header, paths, lang='c'):
26 caltinay 3214 from SCons.Script.SConscript import Configure
27 caltinay 3212 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 caltinay 3229 conf=Configure(env.Clone())
60 caltinay 3212 conf.env.AppendUnique(CPPPATH = [inc_path])
61     conf.env.AppendUnique(LIBPATH = [lib_path])
62     if type(libs)==str: libs=[libs]
63 caltinay 3214 # 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 caltinay 3212
70     conf.Finish()
71     return inc_path, lib_path
72    
73 caltinay 3975 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 gross 3580
85 jgs 268 # Code to build .pyc from .py
86     def build_py(target, source, env):
87 gross 3580 try:
88     py_compile.compile(str(source[0]), str(target[0]), doraise=True)
89     return 0
90 gross 3581 except py_compile.PyCompileError, e:
91 gross 3580 print e
92     return 1
93    
94 jgs 297
95     # Code to run unit_test executables
96     def runUnitTest(target, source, env):
97 ksteube 1312 time_start = time.time()
98     app = str(source[0].abspath)
99 gross 2502 pn, sn= os.path.split(app)
100 gross 2363 if not os.name== "nt":
101 caltinay 3376 app = "cd "+pn+"; "+os.path.join(env['bininstall'], "run-escript")+" -bv "+os.path.join('.',sn)
102 gross 2416 else:
103     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"\
106 gross 2502 %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)
107     else:
108 trankine 2629 app = "cd "+ pn +" & "+sn
109 ksteube 1312 print "Executing test: " + app
110     if not env.Execute(app):
111 jgs 297 open(str(target[0]),'w').write("PASSED\n")
112 ksteube 1312 else:
113     return 1
114     print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)
115     return None
116 cochrane 370
117 robwdcock 682 def runPyUnitTest(target, source, env):
118 ksteube 1312 time_start = time.time()
119     app = str(source[0].abspath)
120 gross 2502 pn, sn= os.path.split(app)
121 gross 2363 if os.name== "nt":
122 gross 2416 if env['usempi']:
123 trankine 2629 app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
124 gross 2423 "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\
125 gross 2502 %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)
126 gross 2416 else:
127 trankine 2629 app = "cd "+ pn +" & "+sys.executable + " " + sn
128 ksteube 1312 else:
129 caltinay 3376 app = "cd "+pn+"; "+os.path.join(env['bininstall'], "run-escript")+" -ov "+sn
130 gross 2502 print "Executing test: ",app
131 gross 1374 if env.Execute(app) == 0:
132 ksteube 1312 open(str(target[0]),'w').write("PASSED\n")
133     else:
134     return 1
135     print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath)
136     return None
137 phornby 1233
138 jfenwick 2387 def eps2pdf(target, source, env):
139 jfenwick 3053 # if env.Execute("epstopdf "+str(source[0].abspath)+" -o "+str(target[0].abspath))!=0:
140 caltinay 3270 if env.Execute("ps2pdf -dEPSCrop "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:
141 jfenwick 2387 return 1
142 jfenwick 2388 return None
143    
144     def effectiveName(inname):
145     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):
147 jfenwick 3047 return "savanna"
148 jfenwick 2388 return inname

  ViewVC Help
Powered by ViewVC 1.1.26