1 |
|
2 |
############################################################################## |
3 |
# |
4 |
# Copyright (c) 2003-2015 by University of Queensland |
5 |
# http://www.uq.edu.au |
6 |
# |
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 |
# Development until 2012 by Earth Systems Science Computational Center (ESSCC) |
12 |
# Development 2012-2013 by School of Earth Sciences |
13 |
# Development from 2014 by Centre for Geoscience Computing (GeoComp) |
14 |
# |
15 |
############################################################################## |
16 |
|
17 |
import os |
18 |
Import('*') |
19 |
|
20 |
from subprocess import PIPE, Popen |
21 |
|
22 |
haveMPL=False # do we have matplotlib? |
23 |
haveGD=False # does matplotlib have griddata? |
24 |
|
25 |
mplmagicversion='0.98.5' |
26 |
|
27 |
# check for matplotlib |
28 |
if env['pythoncmd']=='python': |
29 |
try: |
30 |
import matplotlib |
31 |
haveMPL=True |
32 |
mplversion=matplotlib.__version__ |
33 |
from matplotlib.mlab import griddata |
34 |
haveGD=True |
35 |
except ImportError: |
36 |
pass |
37 |
else: |
38 |
# we need to fire up the external command |
39 |
p=Popen([env['pythoncmd'], '-c', 'from __future__ import print_function;import matplotlib;print(matplotlib.__version__);from matplotlib.mlab import griddata;print("1")'], stdout=PIPE) |
40 |
try: |
41 |
mplversion=p.stdout.readline().strip() |
42 |
if mplversion!='': |
43 |
haveMPL=True |
44 |
hgd=p.stdout.readline().strip() |
45 |
haveGD=True |
46 |
except IOError: |
47 |
pass |
48 |
p.wait() |
49 |
|
50 |
if not haveMPL: |
51 |
env['warnings'].append("matplotlib not found, will skip some unit tests") |
52 |
else: |
53 |
if mplversion<mplmagicversion: |
54 |
env['warnings'].append("matplotlib found, but version too early. Some unit tests will be skipped.") |
55 |
|
56 |
example_files_allow_mpi = [] |
57 |
example_files_no_mpi = [] |
58 |
example_deps = [] |
59 |
skipped_tests = [] |
60 |
|
61 |
def sortOutExample(name, needsGMSH=False, needsMPL=False, needsMagicMPL=False, needsGD=False, allowsMPI=True): |
62 |
if needsMagicMPL: needsMPL=True |
63 |
if needsGD: needsMPL=True |
64 |
if needsGMSH: allowsMPI=False |
65 |
|
66 |
if needsGMSH and not env['gmsh']: |
67 |
skipped_tests.append(name) |
68 |
return |
69 |
|
70 |
if (not needsGMSH or env['gmsh']) and (not needsMPL or haveMPL) and (not needsMagicMPL or mplversion>=mplmagicversion) and (not needsGD or haveGD): |
71 |
if allowsMPI: |
72 |
example_files_allow_mpi.append(name) |
73 |
else: |
74 |
example_files_no_mpi.append(name) |
75 |
else: |
76 |
example_deps.append(name) |
77 |
|
78 |
# these are the release examples in example subdirectory: |
79 |
# |
80 |
#_deps is for files which end in .py and are required for |
81 |
# testing but should not be invoked directly themselves |
82 |
|
83 |
sortOutExample('usersguide/lid_driven_cavity.py') |
84 |
sortOutExample('usersguide/mount.py') |
85 |
sortOutExample('usersguide/heatedblock.py') |
86 |
sortOutExample('usersguide/helmholtz.py') |
87 |
sortOutExample('usersguide/fluid.py') |
88 |
sortOutExample('usersguide/poisson.py') |
89 |
sortOutExample('usersguide/diffusion.py') |
90 |
sortOutExample('usersguide/poisson_vtk.py') |
91 |
sortOutExample('usersguide/darcy.py') |
92 |
sortOutExample('usersguide/slip.py') |
93 |
sortOutExample('usersguide/int_save.py') |
94 |
sortOutExample('usersguide/wave.py', needsMPL=True) |
95 |
sortOutExample('usersguide/trapezoid.py', needsGMSH=True, allowsMPI=False) |
96 |
sortOutExample('usersguide/quad.py', needsGMSH=True) |
97 |
sortOutExample('usersguide/brick.py', needsGMSH=True) |
98 |
sortOutExample('usersguide/refine.py', needsGMSH=True) |
99 |
sortOutExample('usersguide/poisson_matplotlib.py', needsGD=True, allowsMPI=False) |
100 |
|
101 |
sortOutExample('geotutorial/steadystate_variablek.py') |
102 |
sortOutExample('geotutorial/steadystate.py') |
103 |
sortOutExample('geotutorial/forward_euler.py') |
104 |
sortOutExample('geotutorial/myfirstscript.py') |
105 |
sortOutExample('geotutorial/backward_euler.py') |
106 |
|
107 |
example_deps.append('cookbook/cblib.py') |
108 |
sortOutExample('cookbook/example01a.py') |
109 |
sortOutExample('cookbook/example01b.py', needsMPL=True) |
110 |
sortOutExample('cookbook/example01c.py', needsMPL=True, allowsMPI=False) |
111 |
sortOutExample('cookbook/example02.py', needsMPL=True, allowsMPI=False) |
112 |
sortOutExample('cookbook/example03a.py', needsGD=True, allowsMPI=False) |
113 |
sortOutExample('cookbook/example03b.py') |
114 |
sortOutExample('cookbook/example04a.py', needsGMSH=True) |
115 |
sortOutExample('cookbook/example04b.py', needsGMSH=True, needsGD=True) |
116 |
sortOutExample('cookbook/example05a.py', needsGMSH=True, needsGD=True) |
117 |
sortOutExample('cookbook/example05b.py', needsGMSH=True, needsGD=True) |
118 |
sortOutExample('cookbook/example05c.py', needsGMSH=True, needsGD=True, needsMagicMPL=True) |
119 |
sortOutExample('cookbook/example06.py', needsGMSH=True, needsGD=True, needsMagicMPL=True) |
120 |
sortOutExample('cookbook/example07a.py', needsMagicMPL=True, allowsMPI=False) |
121 |
sortOutExample('cookbook/example07b.py', needsMagicMPL=True, allowsMPI=False) |
122 |
sortOutExample('cookbook/example08a.py', needsMagicMPL=True, allowsMPI=False) |
123 |
sortOutExample('cookbook/example08b.py', needsMagicMPL=True, allowsMPI=False) |
124 |
sortOutExample('cookbook/example08c.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False) |
125 |
sortOutExample('cookbook/example09m.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False) |
126 |
sortOutExample('cookbook/example09a.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False) |
127 |
#sortOutExample('cookbook/example09b.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False) |
128 |
sortOutExample('cookbook/example10a.py', needsMagicMPL=True, allowsMPI=False) |
129 |
sortOutExample('cookbook/example10b.py', needsMagicMPL=True, allowsMPI=False) |
130 |
sortOutExample('cookbook/example10m.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False) |
131 |
#sortOutExample('cookbook/example10c_0.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False) |
132 |
#sortOutExample('cookbook/example10c_1.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False) |
133 |
sortOutExample('cookbook/example11a.py', needsMagicMPL=True, allowsMPI=False) |
134 |
sortOutExample('cookbook/example11b.py', needsMagicMPL=True, allowsMPI=False) |
135 |
|
136 |
sortOutExample('inversion/create_netcdf.py') |
137 |
sortOutExample('inversion/grav_ermapper.py') |
138 |
sortOutExample('inversion/grav_netcdf.py') |
139 |
sortOutExample('inversion/gravmag_netcdf.py') |
140 |
sortOutExample('inversion/gravmag_nodriver.py') |
141 |
sortOutExample('inversion/mag_netcdf.py') |
142 |
sortOutExample('inversion/plot_ermapper.py', needsMPL=True, allowsMPI=False) |
143 |
sortOutExample('inversion/plot_netcdf.py', needsMPL=True, allowsMPI=False) |
144 |
sortOutExample('inversion/dc_forward.py', needsGMSH=True) |
145 |
example_deps.append('inversion/content.txt') |
146 |
example_deps.append('inversion/data/GravitySmall') |
147 |
example_deps.append('inversion/data/MagneticSmall') |
148 |
example_deps.append('inversion/data/QLDWestGravity') |
149 |
example_deps.append('inversion/data/QLDWestMagnetic') |
150 |
example_deps.append('inversion/data/GravitySmall.ers') |
151 |
example_deps.append('inversion/data/MagneticSmall.ers') |
152 |
example_deps.append('inversion/data/QLDWestGravity.ers') |
153 |
example_deps.append('inversion/data/QLDWestMagnetic.ers') |
154 |
example_deps.append('inversion/data/GravitySmall.nc') |
155 |
example_deps.append('inversion/data/MagneticSmall.nc') |
156 |
example_deps.append('inversion/data/QLDWestGravity.nc') |
157 |
example_deps.append('inversion/data/QLDWestMagnetic.nc') |
158 |
example_deps.append('inversion/data/HalfSphere_v1.4.msh') |
159 |
|
160 |
|
161 |
|
162 |
|
163 |
if len(skipped_tests)>0: |
164 |
env['warnings'].append("gmsh not available. Skipping tests %s!"%' '.join(skipped_tests)) |
165 |
|
166 |
example_files = example_files_allow_mpi + example_files_no_mpi + example_deps |
167 |
|
168 |
ex2=[os.path.join("examples", str(x)) for x in example_files] |
169 |
|
170 |
#============================================================================= |
171 |
|
172 |
local_env = env.Clone() |
173 |
src_dir = local_env.Dir('.').srcnode().abspath |
174 |
release_dir=os.path.join(env['prefix'],'release','doc') |
175 |
Export('release_dir') |
176 |
|
177 |
dir_cmd = "cd "+src_dir+" && " |
178 |
|
179 |
# Need to use explicit tar/zip rather than the builder due to problems getting |
180 |
# it not to put unwanted path components in the archive file |
181 |
# --transform on tar is not supported on savanna |
182 |
zip_path=os.path.join(release_dir, 'escript_examples.zip') |
183 |
zip = local_env.Command(zip_path, None, dir_cmd+"zip "+zip_path+" "+" ".join(ex2)) |
184 |
env.Alias('examples_zipfile', zip) |
185 |
|
186 |
tar_path=os.path.join(release_dir, 'escript_examples.tar.gz') |
187 |
tar = local_env.Command(tar_path, None, dir_cmd+"tar -czf "+tar_path+" "+" ".join(ex2)) |
188 |
env.Alias('examples_tarfile', tar) |
189 |
|
190 |
#env=Environment(TARFLAGS = "-c -z",chdir=src_dir) |
191 |
#if 'Tar' in dir(env): |
192 |
# tar=env.Tar(tar_path, example_files, chdir=src_dir) |
193 |
# env.Alias('examples_tarfile', tar) |
194 |
|
195 |
local_env.SConscript(dirs = ['#/doc/cookbook'], variant_dir='cookbook', duplicate=1) |
196 |
local_env.SConscript(dirs = ['#/doc/user'], variant_dir='user', duplicate=1) |
197 |
local_env.SConscript(dirs = ['#/doc/inversion'], variant_dir='inversion', duplicate=1) |
198 |
local_env.SConscript(dirs = ['#/doc/epydoc'], variant_dir='epydoc', duplicate=1) |
199 |
local_env.SConscript(dirs = ['#/doc/sphinx_api'], variant_dir='sphinx_api', duplicate=1) |
200 |
local_env.SConscript(dirs = ['#/doc/doxygen'], variant_dir='doxygen', duplicate=1) |
201 |
local_env.SConscript(dirs = ['#/doc/install'], variant_dir='install', duplicate=1) |
202 |
local_env.SConscript(dirs = ['#/doc/examples'], variant_dir='examples', duplicate=1, exports=['example_files_allow_mpi', 'example_files_no_mpi', 'example_deps']) |
203 |
|