User Tools

Site Tools


howto:compiling_python_2_7_3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howto:compiling_python_2_7_3 [2012/09/17 15:06]
adymond [Test]
howto:compiling_python_2_7_3 [2021/12/09 16:42] (current)
Line 233: Line 233:
   $ python setup.py install   $ python setup.py install
  
-==== Numpy ====+==== NumPy and SciPy====
  
 [[http://numpy.scipy.org/|NumPy]] is the fundamental package for scientific computing with Python. It [[http://numpy.scipy.org/|NumPy]] is the fundamental package for scientific computing with Python. It
Line 244: Line 244:
  
 Based on [[http://www.scipy.org/Installing_SciPy/Linux|installation guide]]. Based on [[http://www.scipy.org/Installing_SciPy/Linux|installation guide]].
- 
- 
-==== Build ATLAS(3.9.32) with complete Lapack(3.2.2) 
- 
-From a temporary director ( ie Scratch ) download the latest atlas from Source 
-forge 
-  $ wget http://www.netlib.org/lapack/lapack-3.4.0.tgz 
-  $ wget http://tenet.dl.sourceforge.net/project/math-atlas/Stable/3.10.0/atlas3.10.0.tar.bz2 
-  $ tar -xf atlas3.10.0.tar.bz2 
-  $ mkdir ATLAS/BUILD 
-  $ cd  ATLAS/BUILD 
-  $ ../configure -b 64 -Fa alg -fPIC --shared \ 
-  --with-netlib-lapack-tarfile=../../lapack-3.4.0.tgz --prefix=$HOME/usr  
-make 
-cd lib 
-make shared 
-make ptshared 
-cd .. 
-make install 
  
 === BLAS and LAPACK libraries === === BLAS and LAPACK libraries ===
Line 291: Line 272:
  -->   LAPACK TESTING SUMMARY  <--  -->   LAPACK TESTING SUMMARY  <--
        Processing LAPACK Testing output found in the TESTING  direcory        Processing LAPACK Testing output found in the TESTING  direcory
-SUMMARY        nb test run numerical error other error   +  SUMMARY        nb test run numerical error other error   
-================       =========== =================       ================   +  REAL         1077227 0 (0.000%) 0   (0.000%)  
-REAL   1077227 0 (0.000%) 0   (0.000%)  +  DOUBLE PRECISION 1078039 0 (0.000%) 0   (0.000%)  
-DOUBLE PRECISION 1078039 0 (0.000%) 0   (0.000%)  +  COMPLEX                 522814 0 (0.000%) 0   (0.000%)  
-COMPLEX 522814 0 (0.000%) 0   (0.000%)  +  COMPLEX16 552410 0 (0.000%) 0   (0.000%)  
-COMPLEX16 552410 0 (0.000%) 0   (0.000%)  +  --> ALL PRECISIONS 3230490 0 (0.000%) 0   (0.000%)
---> ALL PRECISIONS 3230490 0 (0.000%) 0   (0.000%)+
  
 if all went well if all went well
   $ cp -iv lib* $HOME/local/lib64   $ cp -iv lib* $HOME/local/lib64
 +  
 +To convert the built static libraries to dynamic libraries, the following bash
 +loop is used
 +  $ for LIB in *.a ; do
 +      DIR=${LIB}_contents
 +      SOLIB=${LIB%.*}.so
 +      echo $SOLIB
 +      mkdir $DIR
 +      cd $DIR
 +      ar -x ../$LIB
 +      cd -
 +      gfortran -shared -Wl,-soname=$SOLIB -o $SOLIB ${DIR}/*.o
 +    done;
 +  $ ln -snf librefblas.so libblas.so
  
-#Compile the shared object (so) or dynamic libraries for blas and lap#ack +Copy the shared object or dynamic libraries to your library folder 
-#  $ gcc -shared BLAS/SRC/*.o -o libblas.so +  $ cp -iv lib*.so $HOME/local/lib64 
-#  $ gcc -shared SRC/*.o -o liblapack.so +[warning dynamic libaries not fully tested] 
-#Basic library checks, +  
-#  $ ipython +
-#    $ from ctypes import * +
-#    $ blaslib = cdll.LoadLibrary('libblas.so') +
-#    $ array = (c_float*4)() +
-#    $ array[:] = [4.0, 3.14159, 4.1, 2.0] +
-#    $ print blaslib.isamax_(byref(c_int(len(array))), array, byref(c_int(1))) +
-#  The output should be 3. +
-#    $ lapacklib = cdll.LoadLibrary('liblapack.so') +
-#    $ n, info = 5, c_int() +
-#    $ diag, offdiag = (c_double*n)(), (c_double*(n-1))() +
-#    $ diag[:], offdiag[:] = [2.0]*n, [-1.0]*(n-1) +
-#    $ r=lapacklib.dsterf_(byref(c_int(n)), diag, offdiag, byref(info)) +
-#    $ print '[', ', '.join('%g'%v for v in diag[:]), ']' +
-#  You should get output like [ 0.267949, 1, 2, 3, 3.73205 ], the eigenvalues +
-#  for this special matrix.  +
- +
-#If so congratulations. Then copy the compiled libaries to your $HOME/usr +
-#directory +
-#  $ cp lib* $HOME/usr/lib +
 === Numpy building, testing and installation === === Numpy building, testing and installation ===
  
-#Download the last version of numpy source, in your scratch folder. 
-#  $ cd ~/scratch 
-#  $ easy_install --editable --build-directory . numpy 
-#  $ cd numpy 
-#Or alternatively 
 Download numpy Download numpy
   $ cd ~/scratch   $ cd ~/scratch
Line 339: Line 308:
   $ cd numpy-1.6.2   $ cd numpy-1.6.2
  
-#Before continuing read both INSTALL.txt and site.cfg.example +== build using shared object libraries == 
-#  $ echo '[DEFAULT]' > site.cfg +  $ echo "[DEFAULT]" > site.cfg 
-#  $ echo "library_dirs = $HOME/usr/lib64:$HOME/usr/lib" >> site.cfg +  $ echo "library_dirs = $HOME/local/lib64" >> site.cfg 
-#  $ echo "include_dirs = $HOME/usr/include:$HOME/usr/include/python2.7" >> site.cfg+  $ echo "include_dirs = $HOME/local/include"  >> site.cfg 
 +  $ python setup.py build --fcompiler=gnu95 
 +  $ python setup.py install
  
  
-#nun python setup.py install. +== build using static lapack and blas libraries (for interests sake only) ==
-#  $ python setup.py build --fcompiler=gnu95 +
-#  $ python setup.py install +
-#started at 09:25 +
- +
-#try unsetting CPPFLAGS , and setting include dirs in set.cfg, +
-#maybe this will avoid +
-#_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’ +
-#[enabled by default] +
-#gcc -pthread _configtest.o -o _configtest +
-#_configtest.o: In function `main': +
-#/tmp/adymond/numpy-1.6.2/_configtest.c:6: undefined reference to `exp' +
-#while -lm (linking to math library should fix that, how do i add that to gcc +
- +
-#  $ unset CPPFLAGS +
-#  $ export CPPFLAGS='-lm' +
- +
- +
-#Sidenote: To compile with BLAS and LAPACK, set the following variables before +
- building +
-#  $ export ATLAS=None +
-#  $ export BLAS=None +
-#  $ export LAPACK=None+
  
 Set blas and lapack paths Set blas and lapack paths
Line 373: Line 322:
   $ export BLAS=$HOME/local/lib64/librefblas.a   $ export BLAS=$HOME/local/lib64/librefblas.a
   $ export LAPACK=$HOME/local/lib64/liblapack.a   $ export LAPACK=$HOME/local/lib64/liblapack.a
- 
 Build and install Build and install
   $ python setup.py build --fcompiler=gnu95   $ python setup.py build --fcompiler=gnu95
-  $ python setup.py install 
  
-Then test it (note this requires nose) +NB to build without lapack and blas libraries, do the following 
-  $ cd ~+  $ export ATLAS=None 
 +  $ export BLAS=None 
 +  $ export LAPACK=None 
 +then build 
 + 
 +speed difference: using LAPACK and BLAS libraries numpy testing takes between 
 +10 and 12s, without the libraries numpy.test() takes exactly the same amount 
 +of time? 
 + 
 +== testing == 
 +  $ mkdir -p /tmp/$USER/numpy-1.6.2_testing 
 +  $ python setup.py install --prefix=/tmp/$USER/numpy-1.6.2_testing
   $ ipython   $ ipython
-  $ import numpy +    $ import os, sys 
-  $ numpy.test() +    $ sys.path.insert(0,'/tmp/%s/numpy-1.6.2_testing/lib/python2.7/site-packages'  % os.environ['USER']) 
-   +    $ import numpy 
- +    $ numpy.test() 
 +If all the test were passed, rm the testing directory and install numpy 
 +  $ rm -r /tmp/$USER/numpy-1.6.2_testing 
 +  $ python setup.py install 
 + 
 === Scipy, minimal install === === Scipy, minimal install ===
  
   $ cd ~/scratch   $ cd ~/scratch
   $ wget http://tenet.dl.sourceforge.net/project/scipy/scipy/0.10.1/scipy-0.10.1.tar.gz   $ wget http://tenet.dl.sourceforge.net/project/scipy/scipy/0.10.1/scipy-0.10.1.tar.gz
-  $ tar -xf scipy-0.10.1.tar.gz +  $ tar -xf scipy-0.10.1.tar.gz
   $ cd scipy-0.10.1/   $ cd scipy-0.10.1/
-Set blas and lapack paths +  $ python setup.py build #takes about 10 minutes to build
-  $ export ATLAS=None +
-  $ export BLAS=$HOME/local/lib64/librefblas.a +
-  $ export LAPACK=$HOME/local/lib64/liblapack.a +
-Build it, which takes a while +
-  $ python setup.py build +
-Install it +
-  $ python setup.py install +
  
- +testing, 
-Once the build has been successfully completed, its time to install and test +  $ mkdir -p /tmp/$USER/scipy-0.10.1 
-scipy +  $ python setup.py install --prefix=/tmp/$USER/scipy-0.10.1_testing
-  $ python setup.py install +
-  $ cd ~+
   $ ipython   $ ipython
-  $ import scipy +    $ import os, sys 
-  $ scipy.test() +    $ sys.path.insert(0,'/tmp/%s/scipy-0.10.1_testing/lib/python2.7/site-packages'  % os.environ['USER']) 
 +    $ import scipy 
 +    $ scipy.test()
 which did not work 100 % :( which did not work 100 % :(
   FAILED (KNOWNFAIL=13, SKIP=41, failures=1)   FAILED (KNOWNFAIL=13, SKIP=41, failures=1)
   Out[2]: <nose.result.TextTestResult run=5101 errors=0 failures=1>   Out[2]: <nose.result.TextTestResult run=5101 errors=0 failures=1>
  
-=== matplotlib / pylab ===+If testing satisfactory, rm the testing directory and install scipy 
 +  $ rm -r /tmp/$USER/scipy-0.10.1_testing 
 +  $ python setup.py install 
 +==== matplotlib / pylab ====
  
   Download latest version from source forge (version 1.1 in this case)   Download latest version from source forge (version 1.1 in this case)
/app/dokuwiki/data/attic/howto/compiling_python_2_7_3.1347887193.txt.gz · Last modified: 2021/12/09 16:42 (external edit)