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:11]
adymond [Numpy]
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 272: 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
 +
 +Copy the shared object or dynamic libraries to your library folder
 +  $ cp -iv lib*.so $HOME/local/lib64
 +[warning dynamic libaries not fully tested]
      
 === Numpy building, testing and installation === === Numpy building, testing and installation ===
Line 289: Line 307:
   $ tar -xf numpy-1.6.2.tar.gz   $ tar -xf numpy-1.6.2.tar.gz
   $ cd numpy-1.6.2   $ cd numpy-1.6.2
-  + 
 +== build using shared object libraries == 
 +  $ echo "[DEFAULT]" > site.cfg 
 +  $ echo "library_dirs = $HOME/local/lib64" >> site.cfg 
 +  $ echo "include_dirs = $HOME/local/include"  >> site.cfg 
 +  $ python setup.py build --fcompiler=gnu95 
 +  $ python setup.py install 
 + 
 + 
 +== build using static lapack and blas libraries (for interests sake only) == 
 Set blas and lapack paths Set blas and lapack paths
   $ export ATLAS=None   $ export ATLAS=None
   $ 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() 
-==== Scipy, minimal install ====+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 ===
  
   $ 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>
  
 +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 ==== ==== matplotlib / pylab ====
  
/app/dokuwiki/data/attic/howto/compiling_python_2_7_3.1347887471.txt.gz · Last modified: 2021/12/09 16:42 (external edit)