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