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:04] adymond [GDB : the GNU debugger] |
howto:compiling_python_2_7_3 [2021/12/09 16:42] (current) |
||
|---|---|---|---|
| Line 128: | Line 128: | ||
| Where | Where | ||
| * dl is depreciated since Python 2.6, use ctypes instead. | * dl is depreciated since Python 2.6, use ctypes instead. | ||
| - | * Beginning in 2.3 some Unix versions of Python may have a bsddb185 | + | * Beginning in 2.3 some Unix versions of Python may have a bsddb185 module. This is present only to allow backwards compatibility with systems which ship with the old Berkeley DB 1.85 database library. The bsddb185 module should never be used directly in new code. The module has been removed in Python 3. If you find you still need it look in PyPI. |
| - | | + | |
| - | | + | |
| - | | + | |
| * imageop and sunaudiodev, | * imageop and sunaudiodev, | ||
| - | used directly in new code. The module has been removed in Python 3. If you find you still need it look in PyPI. | ||
| - | * the audio and image operation modules, arent assumed unneeded. | ||
| - | |||
| ===== Test ===== | ===== Test ===== | ||
| Line 164: | Line 158: | ||
| As for test_gdb, which i assume is the GNU debugger interfacing module, more | As for test_gdb, which i assume is the GNU debugger interfacing module, more | ||
| information on the error can be obtained by | information on the error can be obtained by | ||
| - | ./python ../ | + | $ ./python ../ |
| If this is good enough for your applications proceed with the installation. | If this is good enough for your applications proceed with the installation. | ||
| Line 239: | Line 233: | ||
| $ python setup.py install | $ python setup.py install | ||
| - | ==== Numpy ==== | + | ==== NumPy and SciPy==== |
| [[http:// | [[http:// | ||
| Line 250: | 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 297: | 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 345: | 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. | + | |
| - | # $ 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 | + | |
| - | # | + | |
| - | #[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 | + | == build using static lapack and blas libraries (for interests sake only) == |
| - | | + | |
| - | # $ export ATLAS=None | + | |
| - | # $ export BLAS=None | + | |
| - | # $ export LAPACK=None | + | |
| Set blas and lapack paths | Set blas and lapack paths | ||
| Line 379: | 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 | ||
| + | |||
| + | NB to build without lapack and blas libraries, do the following | ||
| + | $ 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 / | ||
| + | $ python setup.py install --prefix=/ | ||
| + | $ ipython | ||
| + | $ import os, sys | ||
| + | $ sys.path.insert(0,'/ | ||
| + | $ import numpy | ||
| + | $ numpy.test() | ||
| + | If all the test were passed, rm the testing directory and install numpy | ||
| + | $ rm -r / | ||
| $ python setup.py install | $ python setup.py install | ||
| - | Then test it (note this requires nose) | + | |
| - | $ cd ~ | + | |
| - | $ ipython | + | |
| - | $ import numpy | + | |
| - | $ numpy.test() | + | |
| - | + | ||
| - | + | ||
| === 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) | ||