Building Scipy

Table of contents

Introduction

The SciPy project provides two packages: NumPy (formerly known as core SciPy) and full SciPy. The NumPy package is a replacement of Numeric and should be installed before building the full SciPy package. Installing both packages is simple. In most cases simply executing

  python setup.py install

in the numpy and scipy directories will install each package. The rest of this document concentrates on configuring, building, installing, or/and using various external software that Scipy can use for extra power.

Python

To build SciPy, Python version 2.3 or newer is required. Make sure that the Python package distutils is installed before continuing. For example, in Debian GNU/Linux, distutils is included in the python-dev package.

Compilers

To build any extension modules for Python, you'll need a C compiler.

Various SciPy modules use Fortran 77 libraries and some use C++, so you'll also need Fortran 77 and C++ compilers installed. The SciPy module Weave uses a C++ compiler at run time.

Note that SciPy is developed mainly using GNU compilers. Compilers from other vendors such as Intel, Absoft, Sun, NAG, Compaq, Vast, Porland, Lahey, HP, IBM are supported in the form of community feedback.

gcc 3.x compilers are recommended. Note that code compiled by the Intel Fortran Compiler (IFC) is not binary compatible with code compiled by g77. Therefore, when using IFC, all Fortran codes used in SciPy must be compiled with IFC. This also includes the LAPACK, BLAS, and ATLAS libraries. Using GCC for compiling C code is OK. IFC version 5.0 is not supported.

To build NumPy, only a C compiler is required.

Linear Algebra libraries

Various SciPy packages do linear algebra computations using the LAPACK routines. SciPy's setup.py scripts can use number of different LAPACK library setups, including optimized LAPACK libraries such as ATLAS or the Accelerate/vecLib framework on OS X. The following notes give detailed information on how to prepare the build environment so that SciPy's setup.py scripts can use whatever LAPACK library setup one has.

NumPy does not require any external linear algebra libraries to be installed. However, if these are available, NumPy's setup script can detect them and use them for building. If you do not plan to build the full SciPy then you can skip this section.

Building BLAS library from Netlib

Download BLAS sources from Netlib, build libfblas.a library, and set environment variable BLAS:

mkdir -p ~/src/blas
cd ~/src/blas
wget http://www.netlib.org/blas/blas.tgz
tar xzf blas.tgz
# When using GNU compiler:
g77 -fno-second-underscore -O2 -c *.f
# OR
# On 64 bit systems with GNU compiler:
g77 -O3 -m64 -fno-second-underscore -fPIC -c *.f
# OR
# Intel compiler:
ifort -FI -w90 -w95 -cm -O3 -unroll -c *.f
ar r libfblas.a *.o
ranlib libfblas.a
rm -rf *.o
export BLAS=~/src/blas/libfblas.a

Building LAPACK library from Netlib

Download LAPACK sources from Netlib, build libflapack.a library, and set environment variable LAPACK:

mkdir -p ~/src
wget http://www.netlib.org/lapack/lapack.tgz
tar xzf lapack.tgz
cd ~/src/LAPACK
cp INSTALL/make.inc.LINUX make.inc             # on LINUX
# Edit make.inc as follows:
PLAT = _Linux
OPTS = -O2
# OR
# On 64 bit systems with GNU compiler:
PLAT = _Linux
OPTS = -O2 -m64 -fPIC
NOOPT = -m64 -fPIC
# OR
# For Absoft (8.x or later):
PLAT = _Linux
OPTS = -O3 -YNO_CDEC
# On LINUX with Intel Fortran compiler:
wget http://www.scipy.org/download/misc/make.inc.LINUX_IFC
cp make.inc.LINUX_IFC make.inc
make lapacklib
make clean
cp lapack_LINUX.a libflapack.a                 # on LINUX
export LAPACK=~/src/LAPACK/libflapack.a
NOTE: scipy may not find the libf* names.  You may have to make a symbolic link from these files to libblas.a and liblapack.a  Numpy does not seem to have this problem.

Further Instructions

More detailed platform-specific instructions for building and installing SciPy can be found on the Installing SciPy page.


Installing SciPy/BuildingGeneral (last edited 2008-07-08 15:27:46 by JamesTurner)