This shows you the differences between two versions of the page.
| 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:// | [[http:// | ||
| Line 244: | Line 244: | ||
| Based on [[http:// | Based on [[http:// | ||
| - | |||
| - | |||
| - | ==== 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:// | ||
| - | $ wget http:// | ||
| - | $ tar -xf atlas3.10.0.tar.bz2 | ||
| - | $ mkdir ATLAS/BUILD | ||
| - | $ cd ATLAS/BUILD | ||
| - | $ ../ | ||
| - | --with-netlib-lapack-tarfile=../ | ||
| - | make | ||
| - | cd lib | ||
| - | make shared | ||
| - | make ptshared | ||
| - | cd .. | ||
| - | make install | ||
| === BLAS and LAPACK libraries === | === BLAS and LAPACK libraries === | ||
| Line 291: | Line 272: | ||
| --> | --> | ||
| | | ||
| - | SUMMARY | + | |
| - | ================ | + | REAL |
| - | REAL | + | DOUBLE PRECISION 1078039 0 (0.000%) 0 |
| - | DOUBLE PRECISION 1078039 0 (0.000%) 0 | + | COMPLEX |
| - | COMPLEX 522814 0 (0.000%) 0 | + | COMPLEX16 552410 0 (0.000%) 0 |
| - | COMPLEX16 552410 0 (0.000%) 0 | + | --> ALL PRECISIONS 3230490 0 (0.000%) 0 |
| - | --> ALL PRECISIONS 3230490 0 (0.000%) 0 | + | |
| if all went well | if all went well | ||
| $ cp -iv lib* $HOME/ | $ cp -iv lib* $HOME/ | ||
| + | | ||
| + | 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, | ||
| + | done; | ||
| + | $ ln -snf librefblas.so libblas.so | ||
| - | # | + | Copy the shared object or dynamic libraries |
| - | # | + | $ cp -iv lib*.so $HOME/local/lib64 |
| - | # | + | [warning dynamic libaries not fully tested] |
| - | #Basic library checks, | + | |
| - | # $ ipython | + | |
| - | # $ from ctypes import * | + | |
| - | # $ blaslib = cdll.LoadLibrary(' | + | |
| - | # $ array = (c_float*4)() | + | |
| - | # $ array[:] = [4.0, 3.14159, 4.1, 2.0] | + | |
| - | # $ print blaslib.isamax_(byref(c_int(len(array))), | + | |
| - | # The output should be 3. | + | |
| - | # $ lapacklib = cdll.LoadLibrary(' | + | |
| - | # $ n, info = 5, c_int() | + | |
| - | # $ diag, offdiag = (c_double*n)(), | + | |
| - | # $ diag[:], offdiag[:] = [2.0]*n, [-1.0]*(n-1) | + | |
| - | # $ r=lapacklib.dsterf_(byref(c_int(n)), | + | |
| - | # $ print ' | + | |
| - | # 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 | + | |
| - | # | + | |
| - | # $ cp lib* $HOME/ | + | |
| === 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]' | + | $ echo "[DEFAULT]" |
| - | # $ echo " | + | $ echo " |
| - | # $ echo " | + | $ echo " |
| + | $ python setup.py build --fcompiler=gnu95 | ||
| + | $ python setup.py install | ||
| - | #nun python setup.py install. | + | == build using static lapack |
| - | # $ python setup.py | + | |
| - | # $ python setup.py install | + | |
| - | #started at 09:25 | + | |
| - | + | ||
| - | #try unsetting CPPFLAGS , and setting include dirs in set.cfg, | + | |
| - | #maybe this will avoid | + | |
| - | # | + | |
| - | #[enabled by default] | + | |
| - | #gcc -pthread _configtest.o -o _configtest | + | |
| - | # | + | |
| - | #/ | + | |
| - | #while -lm (linking to math library should fix that, how do i add that to gcc | + | |
| - | + | ||
| - | # $ unset CPPFLAGS | + | |
| - | # $ export CPPFLAGS=' | + | |
| - | + | ||
| - | + | ||
| - | #Sidenote: To compile with BLAS and LAPACK, set the following variables before | + | |
| - | | + | |
| - | # $ 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/ | $ export BLAS=$HOME/ | ||
| $ export LAPACK=$HOME/ | $ export LAPACK=$HOME/ | ||
| - | |||
| 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() | ||
| + | of time? | ||
| + | |||
| + | == testing == | ||
| + | $ mkdir -p / | ||
| + | $ python setup.py install --prefix=/ | ||
| $ ipython | $ ipython | ||
| - | | + | |
| - | $ numpy.test() | + | $ sys.path.insert(0,'/ |
| - | + | $ import numpy | |
| - | + | | |
| + | If all the test were passed, rm the testing directory and install numpy | ||
| + | | ||
| + | $ python setup.py install | ||
| + | |||
| === Scipy, minimal install === | === Scipy, minimal install === | ||
| $ cd ~/scratch | $ cd ~/scratch | ||
| $ wget http:// | $ wget http:// | ||
| - | $ 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 | + | |
| - | $ export ATLAS=None | + | |
| - | $ export BLAS=$HOME/ | + | |
| - | $ export LAPACK=$HOME/ | + | |
| - | Build it, which takes a while | + | |
| - | | + | |
| - | 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 |
| - | $ python setup.py install | + | |
| - | | + | |
| $ ipython | $ ipython | ||
| - | | + | |
| - | $ scipy.test() | + | $ sys.path.insert(0,'/ |
| + | $ import scipy | ||
| + | | ||
| which did not work 100 % :( | which did not work 100 % :( | ||
| FAILED (KNOWNFAIL=13, | FAILED (KNOWNFAIL=13, | ||
| Out[2]: < | Out[2]: < | ||
| - | === matplotlib / pylab === | + | If testing satisfactory, |
| + | $ rm -r / | ||
| + | $ 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) | ||