[SciPy-dev] Building numpy/scipy on RHEL5 OR CentOS5

Phil Austin phaustin@gmail....
Mon Jun 23 11:50:37 CDT 2008


Michael Hearne wrote:
> I've been wrestling with installing scipy (in any form - binary, source, 
> egg, rpm) on some RHEL5 machines that I am compelled to work with, and 
> have failed miserably.   I noticed a thread a few months back about 
> building scipy on CentOS 5, and noticed that at least one of the 
> respondents indicated he'd had success.  As I understand it, CentOS 
> strives for binary compatibility with RHEL, so I'm hopeful that CentOS 
> solutions will work for me.
> 

I do this pretty regularly with numpy/scipy/matplotlib from svn
for Centos 5.1 on x86_64.  I build ATLAS and lapack from scratch
but use the fftw3 rpms

~ phil@owl% rpm -qa | grep fftw3
fftw3-3.1.1-1.el5.rf
fftw3-devel-3.1.1-1.el5.rf

The major problem I encountered compared to earlier builds with
Mandrake was the fact that 'fPIC' needs to be explicitly passed
to every fortran, C and C++ compiler call.  There is a bug in
the lapack makefile, for example, that drops 'fPIC' from 4 lapack
compile statements (out of hundreds) and these have to
recompiled by hand  (See step 3 below).

The following is a cut and paste from a fairly disorganized set
of notes.

1) build python

export CPPFLAGS='-fPIC'
export CFLAGS='-fPIC'
export FFLAGS='-fPIC'

./configure --prefix=/users/user-soft/usr251_Centos

make install

2) build ATLAS

mkdir build
cd build
/home/datatmp/phil/install/ATLAS/mybuild phil@owl% \
../configure --prefix=/home/phil/usr251_Centos \
        --cflags='-fPIC'  -Fa alg -fPIC

make install

3) build LAPACK

for lapack: cp INSTALL/make.inc.LINUX  ~/install/lapack-3.1.1/make.inc
and edit:

FORTRAN  = gfortran
OPTS     = -funroll-all-loops -O3 -fPIC
DRVOPTS  = $(OPTS)
NOOPT    =
LOADER   = gfortran
LOADOPTS =

BLASLIB      = /home/phil/usr251_Centos/lib/libcblas.a
LAPACKLIB    = lapack$(PLAT).a
TMGLIB       = tmglib$(PLAT).a
EIGSRCLIB    = eigsrc$(PLAT).a
LINSRCLIB    = linsrc$(PLAT).a

!!and then rebuild these individual routines with fPIC -- recompile!

~/install/transport/lapack-3.1.1/SRC
gfortran  -fPIC  -c slaruv.f -o slaruv.o
gfortran -fPIC -c dlaruv.f -o dlaruv.o

~/install/transport/lapack-3.1.1/INSTALL

gfortran -fPIC -c slamch.f -o slamch.o
gfortran  -fPIC -c dlamch.f -o dlamch.o
gfortran  -fPIC -o testieee tstiee.o

make liblapack
make libblas  then
make all  -- to build vanilla blas and testing
make lapack_install -- to get statistics

Now merge ATLAS and lapack:

cd /home/datatmp/phil/install/ATLAS/mybuild/lib

     cp liblapack.a liblapack_orig.a
     mkdir tmp; cd tmp
     ar x ../liblapack.a
     cp ~/install/transport/lapack-3.1.1/lapack_LINUX.a ../liblapack.a
     ar r ../liblapack.a *.o
     cd ..; rm -rf tmp
     cp liblapack.a /home/phil/usr251_Centos/lib/


and

cp lapack_LINUX.a /home/phil/usr251_Centos/lib/liblapack.a
cp blas_LINUX.a /home/phil/usr251_Centos/lib/libblas.a

the edit numpy site.cfg and add the library locations:

[atlas]
# system_info.py searches atlas and lapack from the following paths
#   library_dir:DEFAULT/atlas*:DEFAULT/ATLAS*:DEFAULT
# where DEFAULT refers to library_dir defined in [DEFAULT] section and
#library_dirs = /usr/lib/3dnow      # Debian Sid
library_dirs = /home/phil/usr251_Centos/lib

# For overriding the names of the atlas libraries:
# atlas_libs = lapack, f77blas, cblas, atlas

[lapack]
library_dirs = /home/phil/usr251_Centos/lib

[lapack_src]
src_dirs = /home/phil/install/transport/lapack-3.1.1/SRC

[blas]
library_dirs = /home/phil/usr251_Centos/lib

[blas_src]
src_dirs = /home/datatmp/phil/install/ATLAS/src/blas

[fftw3]
library_dirs = /usr/lib64/
fftw_libs = fftw3
#fftw_opt_libs = fftw_threaded, rfftw_threaded
# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs



4) build numpy

python setup.py build --fcompiler=gnu95
python setup.py install --fcompiler=gnu95  install

make sure site.cfg has been copied to

/home/phil/usr251_Centos/lib/python2.5/site-packages\
   /numpy/distutils/site.cfg


5) build scipy

python setup.py build --fcompiler=gnu95
python setup.py install --fcompiler=gnu95  install




More information about the Scipy-dev mailing list