forked from b45ch1/pycppad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·253 lines (253 loc) · 6.28 KB
/
build.sh
File metadata and controls
executable file
·253 lines (253 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#! /bin/bash -e
pycppad_version='20140710'
# ----------------------------------------------------------------------------
#
# exit on any error
set -e
#
if [ "$1" != "omhelp" ] && \
[ "$1" != "sdist" ] && \
[ "$1" != "all" ]
then
echo "build.sh option, where option is one of the following"
echo "omhelp: stop when the help is done"
echo "sdist: stop when the done building the source distribution"
echo "all: go all the way"
exit 1
fi
option="$1"
# ---------------------------------------------------------------------
external_dir=`pwd`/external # externals are placed here
log_dir=`pwd` # build progress logs written here
cppad_download_dir='http://www.coin-or.org/download/source/CppAD'
omhelp_download_dir='http://www.seanet.com/~bradbell'
# ----------------------------------------------------------------------------
# Update setup.py so it corresponds to current build.sh options above.
# only edit line corresponding to assignment statement, check not a == case
echo "sed < setup.py > setup.py.new"
sed < setup.py > setup.py.new \
-e "s|\([\t ]*version *=\).*|\1 '$pycppad_version',|"
if ! diff setup.py setup.py.new > /dev/null
then
echo "Replacing setup.py using changes in setup.py.new"
chmod +x setup.py.new
mv setup.py.new setup.py
else
echo "rm setup.py.new"
rm setup.py.new
fi
# ----------------------------------------------------------------------------
if [ ! -d external ]
then
echo "mkdir external"
mkdir external
fi
cd external
if ! (ls | grep omhelp-) > /dev/null
then
count="0"
else
count=`ls | grep omhelp- | wc -l`
fi
if [ "$count" != "1" ]
then
if [ "$count" != "0" ]
then
echo "rm -r omhelp-*"
rm -r omhelp-*
fi
if [ -e OMhelp.unix.tar.gz ]
then
echo "rm OMhelp.unix.tar.gz"
rm OMhelp.unix.tar.gz
fi
echo "curl -O $omhelp_download_dir/OMhelp.unix.tar.gz"
curl -O "$omhelp_download_dir/OMhelp.unix.tar.gz"
#
echo "tar -xzf OMhelp.unix.tar.gz"
tar -xzf OMhelp.unix.tar.gz
#
echo "cd omhelp-*"
cd omhelp-*
#
omhelp_dir=`pwd`
#
echo "./configure --prefix=$omhelp_dir/prefix"
./configure --prefix="$omhelp_dir/prefix"
#
echo "make install"
make install
#
cd ..
fi
count=`ls | grep omhelp-* | wc -l`
if [ "$count" != "1" ]
then
echo "There should be one and only on omhelp-* directory in external"
exit 1
fi
omhelp_dir=`ls | grep omhelp-`
cd ..
omhelp_dir="$external_dir/$omhelp_dir"
#
# check that every example file is documented
for file in example/*.py
do
name=`echo $file | sed -e 's|example/||'`
if ! grep "$name" omh/example.omh > /dev/null
then
echo "build.sh: $file is not listed in omh/example.omh"
exit 1
fi
done
#
# Change doc.omh and install.omh to use pycppad version in this file
for file in doc.omh omh/install.omh
do
echo "sed < $file > $file.new"
sed < $file > $file.new \
-e "s/pycppad-[0-9]\{8\}/pycppad-$pycppad_version/"
if ! diff $file $file.new > /dev/null
then
echo "Replacing $file using changes in $file.new"
mv $file.new $file
else
echo "rm $file.new"
rm $file.new
fi
done
#
if [ -e doc ]
then
echo "rm -r doc"
rm -r doc
fi
echo "mkdir doc"
mkdir doc
#
echo "cd doc"
cd doc
#
echo "omhelp ../doc.omh -xml -noframe -debug > omhelp.log"
$omhelp_dir/prefix/bin/omhelp \
../doc.omh -xml -noframe -debug > $log_dir/omhelp.log
if grep '^OMhelp Warning:' $log_dir/omhelp.log
then
echo "build.sh: There are warnings in omhelp.log"
exit 1
fi
echo "omhelp ../doc.omh -xml -noframe -debug -printable > /dev/null"
$omhelp_dir/prefix/bin/omhelp \
../doc.omh -xml -noframe -debug -printable > /dev/null
#
echo "omhelp ../doc.omh -noframe -debug > /dev/null"
$omhelp_dir/prefix/bin/omhelp \
../doc.omh -noframe -debug > /dev/null
#
echo "omhelp ../doc.omh -noframe -debug -printable > /dev/null"
$omhelp_dir/prefix/bin/omhelp \
../doc.omh -noframe -debug -printable > /dev/null
#
cd ..
if [ "$option" == "omhelp" ]
then
exit 0
fi
# ----------------------------------------------------------------------------
for dir in dist pycppad-$pycppad_version
do
if [ -e "$dir" ]
then
echo "rm -r $dir"
rm -r $dir
fi
done
echo "create MANIFEST.in"
cat << EOF > MANIFEST.in
include pycppad/*.cpp
include pycppad/*.hpp
include build.sh
include setup.py
include example/*.py
include doc.omh
include doc/*
include README
include test_more.py
include test_example.py
EOF
echo "./setup.py sdist > setup.log"
./setup.py sdist > $log_dir/setup.log
if [ "$option" == "sdist" ]
then
exit 0
fi
# ----------------------------------------------------------------------------
cmd="cd dist"
cd dist
#
echo "tar -xzf pycppad-$pycppad_version.tar.gz"
tar -xzf pycppad-$pycppad_version.tar.gz
#
echo "cd pycppad-$pycppad_version"
cd pycppad-$pycppad_version
#
echo "./setup.py build_ext --inplace --debug --undef NDEBUG >> setup.log"
./setup.py build_ext --inplace --debug --undef NDEBUG >> $log_dir/setup.log
#
if [ ! -e pycppad/cppad_.so ] && [ ! -e pycppad/cppad_.dll ]
then
dir=`pwd`
echo "build.sh: setup.py failed to create $dir/pycppad/cppad_.so"
exit 1
fi
# ----------------------------------------------------------------------------
echo "python test_example.py > test_example.log"
python test_example.py > $log_dir/test_example.log
#
number=`grep '^All' $log_dir/test_example.log | \
sed -e 's|All \([0-9]*\) .*|\1|'`
check=`cat example/*.py | grep '^def' | wc -l`
if [ "$number" != "$check" ]
then
echo "build.sh: Expected $check tests but only found $number"
exit 1
fi
echo "python test_more.py True > test_more.log"
python test_more.py True > $log_dir/test_more.log
#
number=`grep '^All' $log_dir/test_more.log | \
sed -e 's|All \([0-9]*\) .*|\1|'`
check=`grep '^def' test_more.py | wc -l`
if [ "$number" != "$check" ]
then
echo "build.sh: Expected $check tests but only found $number"
exit 1
fi
#
dir=`pwd`
prefix_dir="$dir/prefix/pycppad"
#
echo "./setup.py install --prefix=$prefix_dir >> setup.log"
./setup.py install --prefix=$prefix_dir >> $log_dir/setup.log
#
if [ -e $prefix_dir/lib64 ]
then
lib="lib64"
else
lib="lib"
fi
python_version=`ls $prefix_dir/$lib`
if [ ! -d $prefix_dir/$lib/$python_version/site-packages/pycppad ]
then
echo "Install failed to create"
echo "$prefix_dir/$python_version/site-packages/pycppad"
exit 1
fi
# ----------------------------------------------------------------------------
if grep -i 'warning' $log_dir/setup.log
then
echo "There are warnings in setup.log"
exit 1
fi
echo "OK: build.sh $1"
exit 0