File: srclinux.tex

package info (click to toggle)
python-escript 5.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 144,252 kB
  • sloc: python: 592,062; cpp: 136,909; ansic: 18,675; javascript: 9,411; xml: 3,384; sh: 740; makefile: 203
file content (317 lines) | stat: -rw-r--r-- 9,135 bytes parent folder | download | duplicates (3)
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 2003-2018 by The University of Queensland
% http://www.uq.edu.au
%
% Primary Business: Queensland, Australia
% Licensed under the Apache License, version 2.0
% http://www.apache.org/licenses/LICENSE-2.0
%
% Development until 2012 by Earth Systems Science Computational Center (ESSCC)
% Development 2012-2013 by School of Earth Sciences
% Development from 2014 by Centre for Geoscience Computing (GeoComp)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Installing from source for \linux}
\label{sec:srclinux}

\subsection{Dependencies}

The following instructions assume you are running the \file{bash} shell.
Comments are indicated with \# characters.
Make sure you have the following installed:
\begin{itemize}
 \item \file{g++} and associated tools.
 \item \file{make}
 % I suspect that these are only needed by VTK and if we aren't using it anymore they could be removed
%  \item \file{libXext.so}\footnote{In Debian this is in the libXext-dev package.}
%  \item \file{libxt.so}\footnote{In Debian this is in the libxt-dev package.}
\end{itemize}

\noindent To compile matplotlib you will also need the following\footnote{For
Debian and Ubuntu users, installing \file{libfreetype6-dev} and
\file{libpng-dev} will be sufficient.} (if your distribution separates
development files, make sure to get the development packages):
\begin{itemize}
 \item \file{freetype2}
 \item \file{zlib}
 \item \file{libpng}
\end{itemize}

\noindent In order to fully test the installation using the unit tests you also
need\footnote{On Debian and Ubuntu this is packaged as \file{libcppunit-dev}}:
\begin{itemize}
 \item \file{cppunit}
\end{itemize}
However, a large number of tests will work without it.

\subsection{Preliminaries}
\label{sec:prelim}
You will also need a copy of the \esfinley source code.
If you retrieved the source using subversion, don't forget that one can use the export command instead of checkout to get a smaller copy.
For additional visualization functionality see Section~\ref{sec:addfunc}.

These instructions will produce the following directory structure:
\begin{itemize}
 \item[] \file{stand} \begin{itemize}
  \item[] \file{escript.d}
  \item[] \file{pkg}
  \item[] \file{pkg_src}
  \item[] \file{build}
  \item[] \file{doc}
 \end{itemize}
\end{itemize}

Before you start copy the \esfinley source into the \file{escript.d} directory.
The following instructions refer to software versions in the \file{escript-support-3-src} bundle.
If you download your own versions of those packages substitute their version numbers and names as appropriate.
There are a number of uses of the \file{make} command in the following instructions.
If your computer has multiple cores/processors you can speed up the compilation process by adding -j 2 after the make command.
For example to use all processors on a computer with 4 cores:
\begin{shellCode}
make
\end{shellCode}
becomes
\begin{shellCode}
make -j 4
\end{shellCode}

\begin{shellCode}
mkdir stand
cd stand
mkdir build doc pkg pkg_src
export PKG_ROOT=$(pwd)/pkg
\end{shellCode}

\subsection{Building the dependencies}

Copy the compressed sources for the packages into \file{stand/pkg_src}.
If you are using the support bundles, decompress them in the stand directory:
\begin{shellCode}
tar -xjf escript-support-3-src.tar.bz2
\end{shellCode}

Copy documentation files into \file{doc} then unpack the archives:

\begin{shellCode}
cd build
tar -jxf ../pkg_src/Python-2.6.2.tar.bz2
tar -jxf ../pkg_src/boost_1_39_0.tar.bz2
tar -zxf ../pkg_src/scons-1.2.0.tar.gz
tar -zxf ../pkg_src/numpy-1.3.0.tar.gz
tar -zxf ../pkg_src/netcdf-4.0.tar.gz
tar -zxf ../pkg_src/matplotlib-0.98.5.3.tar.gz
\end{shellCode}

\begin{itemize}

\item Build Python:
\begin{shellCode}
cd Python*
./configure --prefix=$PKG_ROOT/python-2.6.2 --enable-shared 2>&1 \
  | tee tt.configure.out
make 
make install 2>&1 | tee tt.make.out

cd ..

export PATH=$PKG_ROOT/python/bin:$PATH
export PYTHONHOME=$PKG_ROOT/python
export LD_LIBRARY_PATH=$PKG_ROOT/python/lib:$LD_LIBRARY_PATH

pushd ../pkg
ln -s python-2.6.2/ python
popd
\end{shellCode}

Run the new python executable to make sure it works.

\item Now build NumPy:
\begin{shellCode}
cd numpy-1.3.0
python setup.py build
python setup.py install --prefix $PKG_ROOT/numpy-1.3.0
cd ..
pushd ../pkg
ln -s numpy-1.3.0 numpy
popd
export PYTHONPATH=$PKG_ROOT/numpy/lib/python2.6/site-packages:$PYTHONPATH
\end{shellCode}

% \begin{shellCode}
% cd numarray-1.5.2
% 
% python setup.py install \
%  --gencode --install-lib=$PKG_ROOT/numarray-1.5.2/lib \
%  --install-headers=$PKG_ROOT=$PKG_ROOT/numarray-1.5.2/include/numarray \ 
%    2>&1 | tee tt.install.out
% 
% 
% export PYTHONPATH=$PKG_ROOT/numarray/lib:$PYTHONPATH
% cd ..
% pushd ../pkg
% ln -s numarray-1.5.2 numarray
% popd
% \end{shellCode}

\item Next build scons:
\begin{shellCode}
cd scons-1.2.0
python setup.py install --prefix=$PKG_ROOT/scons-1.2.0

export PATH=$PKG_ROOT/scons/bin:$PATH
cd ..
pushd ../pkg
ln -s scons-1.2.0 scons
popd
\end{shellCode}

\item The Boost libraries...:
\begin{shellCode}
pushd ../pkg
mkdir boost_1_39_0
ln -s boost_1_39_0 boost
popd
cd boost_1_39_0
./bootstrap.sh --with-libraries=python --prefix=$PKG_ROOT/boost
./bjam
./bjam install --prefix=$PKG_ROOT/boost --libdir=$PKG_ROOT/boost/lib
export LD_LIBRARY_PATH=$PKG_ROOT/boost/lib:$LD_LIBRARY_PATH
cd ..
pushd ../pkg/boost/lib/
ln *.so.* libboost_python.so
popd
\end{shellCode}

\item ...and netCDF:
\begin{shellCode}
cd netcdf-4.0
CFLAGS="-O2 -fPIC -Df2cFortran" CXXFLAGS="-O2 -fPIC -Df2cFortran" \
FFLAGS="-O2 -fPIC -Df2cFortran" FCFLAGS="-O2 -fPIC -Df2cFortran" \
./configure --prefix=$PKG_ROOT/netcdf-4.0

make 
make install

export LD_LIBRARY_PATH=$PKG_ROOT/netcdf/lib:$LD_LIBRARY_PATH
cd ..
pushd ../pkg
ln -s netcdf-4.0 netcdf
popd
\end{shellCode}

\item Finally matplotlib:
\begin{shellCode}
cd matplotlib-0.98.5.3
python setup.py build
python setup.py install --prefix=$PKG_ROOT/matplotlib-0.98.5.3
cd ..
pushd ../pkg
ln -s matplotlib-0.98.5.3 matplotlib
popd
cd ..
\end{shellCode}

\end{itemize}

\subsection{Compiling escript}\label{sec:compileescriptlinux}

Change to the directory containing your escript source (\file{stand/escript.d}), then:

\begin{shellCode}
cd escript.d/scons
cp TEMPLATE_linux.py YourMachineName_options.py

echo $PKG_ROOT
\end{shellCode}
Where \texttt{YourMachineName} is the name of your computer as returned by the hostname command.
If the name contains non-alphanumeric characters, then you will need to replace them with underscores.
For example the options file for \texttt{bob-desktop} would be named \file{bob_desktop_options.py}.
If you wish to build with OpenMP, MPI or configure other aspects of the system take a quick look at Section~\ref{sec:compilesrc}.


You will need to edit your options file and specify where to find boost and netcdf.
(replace \file{x/stand} with the path to \file{stand})

\begin{python}
#boost_prefix = '/usr/local'
\end{python}

should be
\begin{python}
boost_prefix = ['x/stand/pkg/boost/include/boost-1_39/', 'x/stand/pkg/boost/lib/']
\end{python}

\begin{python}
#netcdf = True
\end{python}

should be
\begin{python}
netcdf = True
\end{python}

\begin{python}
#netcdf_prefix = '/usr/local'
\end{python}

should be \begin{python}
netcdf_prefix = ['x/stand/pkg/netcdf/include/', 
			'x/stand/pkg/netcdf/lib/']
\end{python}

% 
% Edit the options file and put the value of PKG_ROOT between the quotes in the PKG_ROOT= line.
% For example:
% \begin{shellCode}
% PKG_ROOT="/home/bob/stand/pkg"
% \end{shellCode}

\begin{shellCode}
cd ../bin
\end{shellCode}

Modify the STANDALONE line of \file{run-escript} to read:
 
STANDALONE=1

Start a new terminal and go to the \file{stand} directory.

\begin{shellCode}
export PATH=$(pwd)/pkg/scons/bin:$PATH
cd escript.d
eval $(bin/run-escript -e)
scons
\end{shellCode}

If you wish to test your build, then you can do the following. 
Note this may take a while if you have a slow processor and/or less than 1GB of RAM.
\begin{shellCode}
scons py_tests
\end{shellCode}
(If you have cppunit installed you can run additional tests using \texttt{scons all_tests}.

\subsection{Cleaning up}
Once you are satisfied, the \file{escript.d/build} and \file{stand/build} directories can be removed.

If you \emph{really} want to save space and do not wish to be able to edit or recompile \esfinley, you can remove the following:
\begin{itemize}
 \item From the \file{escript.d} directory:\begin{itemize}
\item Everything except: \file{bin}, \file{include}, \file{lib}, \file{esys},
\file{README_LICENSE}.
\item Hidden files, which can be removed using
\begin{shellCode}
find . -name '.?*' | xargs rm -rf
\end{shellCode}
in the \file{escript.d} directory.
\end{itemize}
\item from the \file{pkg} directory:
\begin{itemize}
\item  \file{scons}, \file{scons-1.2.0}
\end{itemize}
\item \file{package\_src}\footnote{Do not remove this if you intend to redistribute.}.
\end{itemize}

Please note that removing all these files may make it more difficult for us to diagnose problems.