This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
howto:compiling_python_2_7_3 [2012/07/27 14:19] kevin created |
howto:compiling_python_2_7_3 [2021/12/09 16:42] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Installing Python 2.7.3 from source on the Sun Tsessbe Cluster ====== | + | ===== Installing Python 2.7.3 from Source |
| - | Before following this guide read through the README file located in the Python Source Install Folder. Also it recommended to make use of temporary or scratch directory to do all the compilation in (i.e. ~/scratch or / | + | This guide follows from GCC 4.7.1 install |
| - | export LD_LIBRARY_PATH=$HOME/ | + | your bash environmental are setup accordingly. Building directory |
| - | export LD_LIBRARY_PATH=$HOME/ | + | |
| - | export PATH=$HOME/ | + | |
| - | export LDFLAGS=" | + | |
| - | export CPPFLAGS=" | + | |
| - | export CXXFLAGS=$CPPFLAGS | + | |
| - | export F77=gfortran | + | |
| - | log out and in again, | + | |
| - | | + | |
| - | gcc (GCC) 4.6.2 | + | |
| - | ===== Prerequisites | + | All libaries and binaries installed in $HOME/local folder, and will require and |
| + | additional 110M of disk space. | ||
| - | Before compiling Python, the zlib library needs to be installed. | ||
| - | | + | ===== Opptional pre-requisites ===== |
| - | $ wget http:// | + | |
| - | $ tar -xf zlib-1.2.6.tar.gz | + | ==== zlib ==== |
| - | $ cd zlib-1.2.6 | + | |
| + | [[ http:// | ||
| + | legally unencumbered -- that is, not covered by any patents -- lossless | ||
| + | data-compression library for use on virtually any computer hardware and | ||
| + | operating system. | ||
| + | |||
| + | | ||
| + | $ wget http:// | ||
| + | $ tar -xf zlib-1.2.7.tar.gz | ||
| + | $ cd zlib-1.2.7 | ||
| + | $ ./configure --prefix=$HOME/ | ||
| $ make | $ make | ||
| - | Test it! | ||
| $ make check | $ make check | ||
| - | Install if all tests pass | + | |
| - | | + | |
| - | ===== Download Source ===== | + | ==== tcl/ |
| - | | + | [[http:// |
| - | $ wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz | + | |
| - | $ tar -xf Python-2.7.3.tgz | + | $ wget http://prdownloads.sourceforge.net/tcl/tcl8.5.12-src.tar.gz |
| - | + | $ tar -xf tcl8.5.12-src.tar.gz | |
| - | ===== Configuration ===== | + | $ cd tcl8.5.12 |
| + | | ||
| + | $ cd BUILD | ||
| + | $ ../ | ||
| + | --enable-64bit --enable-64bit-vis | ||
| + | $ make | ||
| + | $ make test | ||
| + | Summary of test results were | ||
| + | Tests ended at Mon Sep 10 16:00:00 SAST 2012 | ||
| + | all.tcl: | ||
| + | Sourced 137 Test Files. | ||
| + | Files with failing tests: httpold.test unixInit.test | ||
| + | If acceptable, proceed | ||
| + | $ make install | ||
| - | $ cd ~/scratch/Python-2.7.3 | + | then tk |
| - | | + | |
| - | | + | $ wget http:// |
| - | | + | $ tar -xf tk8.5.12-src.tar.gz |
| - | + | | |
| - | ===== Build ===== | + | $ cd tk8.5.12/BUILD |
| + | $ ../unix/ | ||
| + | | ||
| + | $ make | ||
| + | $ make install | ||
| - | $ make | + | ==== sqlite 3 ==== |
| - | If errors occur such as | + | [[ http:// |
| - | * g++: Internal error: Killed (program cc1plus) | + | serverless, zero-configuration, |
| - | wait a while and then make again, as the process was killed by the usage limiter which runs on the login node. If nessary try the approach shown in [[guide:compiling_gcc# | + | |
| - | ===== Check ===== | + | $ cd / |
| + | $ wget http:// | ||
| + | $ tar -xf sqlite-autoconf-3071400.tar.gz | ||
| + | $ cd sqlite-autoconf-3071400 | ||
| + | $ mkdir BUILD | ||
| + | $ cd BUILD | ||
| + | $ ../ | ||
| + | $ make | ||
| + | no tests with package? | ||
| + | $ make install | ||
| - | | + | Got warnings |
| + | ldconfig: | ||
| - | No news is good news: If this test command completes with out an error you know that Python has been compiled successfully. | + | Where ELF = Executable and Linkable Format (ELF, formerly called Extensible |
| + | Linking Format). This is assumed okay as these are python module files, and | ||
| + | not shared object files. The .so.10.0.0-gdb.py extention is probabily | ||
| + | confusing ldconfig, as least i hope. | ||
| - | ===== Install | + | Online docs also indicate that reconfiguring ld may fix the problem. If there |
| + | is problem, try reinstalling binutils? | ||
| + | |||
| + | ==== GDB : the GNU debugger | ||
| + | |||
| + | $ download_and_install_from_source.sh \ | ||
| + | http:// | ||
| + | / | ||
| + | |||
| + | Testing took 20 minutes | ||
| + | Got quite a lot of failures here... | ||
| + | |||
| + | FIXME please... | ||
| + | ===== Download and Configuration ===== | ||
| + | |||
| + | $ cd / | ||
| + | $ wget http:// | ||
| + | $ tar -xf Python-2.7.3.tar.bz2 | ||
| + | $ mkdir Python-2.7.3/ | ||
| + | $ cd Python-2.7.3/ | ||
| + | $ ../ | ||
| + | |||
| + | Does thread support work? if not add the --with-threads=no option to the above | ||
| + | configure | ||
| + | |||
| + | |||
| + | ===== Compile ===== | ||
| + | |||
| + | $ screen | ||
| + | $ make > make.out 2>& | ||
| + | # ctrl-a ctrl-d to detach screen | ||
| + | $ tail -f make.out # to watch compilation progress | ||
| + | |||
| + | giving | ||
| + | |||
| + | Python build finished, but the necessary bits to build these modules were not | ||
| + | found: | ||
| + | bsddb185 | ||
| + | sunaudiodev | ||
| + | To find the necessary bits, look in setup.py in detect_modules() for the | ||
| + | module' | ||
| + | |||
| + | Where | ||
| + | * dl is depreciated since Python 2.6, use ctypes instead. | ||
| + | * 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, | ||
| + | ===== Test ===== | ||
| + | |||
| + | $ screen | ||
| + | $ make test > make.test 2>& | ||
| + | # ctrl-a ctrl-d to detach screen | ||
| + | $ tail -f make.test | ||
| + | |||
| + | Test Summary: | ||
| + | 352 tests OK. | ||
| + | 1 test failed: | ||
| + | | ||
| + | 36 tests skipped: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 2 skips unexpected on linux2: | ||
| + | | ||
| + | The unexpected test were | ||
| + | skipped -- tk not available: no display name and no $DISPLAY environment variable | ||
| + | |||
| + | As for test_gdb, which i assume is the GNU debugger interfacing module, more | ||
| + | information on the error can be obtained by | ||
| + | $ ./python ../ | ||
| + | |||
| + | If this is good enough for your applications proceed with the installation. | ||
| + | |||
| + | ===== Installation | ||
| $ make install | $ make install | ||
| - | | + | $ ln -s ~/local/ |
| - | If your PATH environmental variable is configured to include | + | |
| + | clean up after yourself, | ||
| + | |||
| + | $ rm -r / | ||
| + | |||
| + | Then you should see the following | ||
| $ python | $ python | ||
| - | Python 2.7.3 (default, | + | Python 2.7.3 (default, |
| - | [GCC 4.6.2] on linux2 | + | [GCC 4.7.1] on linux2 |
| Type " | Type " | ||
| - | | + | >>> |
| - | + | ||
| - | ===== Installing | + | ===== Installing |
| - | Before beginning make sure bash environmental variables do not cause a conflict | + | ==== setupTools ==== |
| - | unset CPPFLAGS | + | |
| - | unset LDFLAGS | + | |
| - | === iPython === | + | Start with python setup tools, as it contains the easy install tool. |
| $ cd ~/scratch | $ cd ~/scratch | ||
| - | $ wget http://archive.ipython.org/release/0.12/ipython-0.12.tar.gz | + | $ wget http://pypi.python.org/packages/source/ |
| - | $ tar -xf ipython-0.12.tar.gz | + | $ tar -xf setuptools-0.6c11.tar.gz |
| - | $ cd ipython-0.12 | + | $ cd setuptools-0.6c11 |
| $ python setup.py install | $ python setup.py install | ||
| + | |||
| + | Refer to the [[http:// | ||
| + | and manual website]] for further information on using easy install. | ||
| + | |||
| + | ==== Nose ==== | ||
| + | |||
| + | Nose is a testing module, used by packages such as Numpy and Scipy. To install | ||
| + | simply | ||
| + | $ easy_install nose | ||
| + | |||
| + | ==== iPython ==== | ||
| + | |||
| + | An enhanced Interactive Python shell, with lots of goodies ... | ||
| + | $ easy_install ipython | ||
| + | |||
| + | ==== mpi4py ==== | ||
| + | |||
| + | [[https:// | ||
| + | [[http:// | ||
| + | Passing Library. | ||
| + | |||
| + | To start we are going to build and test the openmpi libraries. | ||
| + | $ cd ~/scratch | ||
| + | $ wget http:// | ||
| + | $ tar -xf openmpi-1.6.1.tar.bz2 | ||
| + | $ cd openmpi-1.6.1 | ||
| + | $ mkdir BUILD | ||
| + | $ cd BUILD | ||
| + | $ ../ | ||
| + | configure taks a minutes or two, with lots of output .... | ||
| + | $ make | ||
| + | $ make check > make.check 2>& | ||
| + | $ grep -i -e pass -e fail make.check | ||
| + | $ make install | ||
| + | |||
| + | Download mpi4py | ||
| + | $ cd ~/scratch | ||
| + | $ easy_install --editable --build-directory . mpi4py | ||
| + | $ cd mpi4py | ||
| + | $ python setup.py build | ||
| + | $ python setup.py test | ||
| + | if no errors install | ||
| + | $ python setup.py install | ||
| + | |||
| + | ==== NumPy and SciPy==== | ||
| + | |||
| + | [[http:// | ||
| + | contains among other things: | ||
| + | |||
| + | * a powerful N-dimensional array object | ||
| + | * sophisticated (broadcasting) functions | ||
| + | * tools for integrating C/C++ and Fortran code | ||
| + | * useful linear algebra, Fourier transform, and random number capabilities | ||
| + | |||
| + | Based on [[http:// | ||
| + | |||
| + | === BLAS and LAPACK libraries === | ||
| + | |||
| + | Following this [[http:// | ||
| + | |||
| + | Download the LAPACK source and extract, setup make and build as follows, | ||
| + | $ cd ~/scratch | ||
| + | $ wget http:// | ||
| + | $ tar -xf lapack-3.4.1.tgz | ||
| + | $ cd lapack-3.4.1 | ||
| + | Setup make, | ||
| + | $ cp make.inc.example make.inc | ||
| + | $ emacs make.inc | ||
| + | # change | ||
| + | # OPTS = -O2 and, NOOPT = -O0 | ||
| + | # to | ||
| + | # OPTS = -O2 -fPIC and, NOOPT = -O0 -fPIC | ||
| + | # save (crtl-x crtl-s) and exit (crtl-x ctrl-c) | ||
| + | $ make blaslib | ||
| + | Make LAPACK | ||
| + | $ screen | ||
| + | $ make all > make.out 2>&1 | ||
| + | # crtl-a d | ||
| + | $ tail -f make.out | ||
| + | |||
| + | After 10 minutes make will finish, and you should see test results such as | ||
| + | --> | ||
| + | | ||
| + | SUMMARY | ||
| + | REAL | ||
| + | DOUBLE PRECISION 1078039 0 (0.000%) 0 | ||
| + | COMPLEX | ||
| + | COMPLEX16 552410 0 (0.000%) 0 | ||
| + | --> ALL PRECISIONS 3230490 0 (0.000%) 0 | ||
| + | |||
| + | if all went well | ||
| + | $ cp -iv lib* $HOME/ | ||
| | | ||
| - | provided | + | 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 to your library folder | ||
| + | $ cp -iv lib*.so | ||
| + | [warning dynamic libaries not fully tested] | ||
| | | ||
| - | === Nose === | + | === Numpy building, testing and installation |
| + | Download numpy | ||
| $ cd ~/scratch | $ cd ~/scratch | ||
| - | $ wget http://pypi.python.org/packages/source/n/nose/nose-1.1.2.tar.gz# | + | $ wget |
| - | $ tar -xf nose-1.1.2.tar.gz | + | $ tar -xf numpy-1.6.2.tar.gz |
| - | $ cd nose-1.1.2 | + | $ cd numpy-1.6.2 |
| + | |||
| + | == build using shared object libraries == | ||
| + | $ echo " | ||
| + | $ echo " | ||
| + | $ echo " | ||
| + | $ python setup.py build --fcompiler=gnu95 | ||
| $ python setup.py install | $ python setup.py install | ||
| - | === Numpy === | ||
| - | Before beginning compile the LAPACK | + | == build using static lapack |
| - | $lapack-3.4.0> | + | |
| - | Download the last version of numpy source, in your scratch folder. Extract it, run python setup.py | + | Set blas and lapack paths |
| - | $ cd ~ | + | $ export ATLAS=None |
| + | $ export BLAS=$HOME/ | ||
| + | $ export LAPACK=$HOME/ | ||
| + | Build and install | ||
| + | $ python setup.py | ||
| + | |||
| + | 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() | ||
| + | of time? | ||
| + | |||
| + | == testing == | ||
| + | $ mkdir -p / | ||
| + | $ python setup.py install --prefix=/ | ||
| $ ipython | $ ipython | ||
| - | | + | |
| - | $ numy.test() | + | $ sys.path.insert(0,'/ |
| - | + | | |
| - | + | $ numpy.test() | |
| - | === matplotlib | + | If all the test were passed, rm the testing directory and install numpy |
| + | $ rm -r /tmp/ | ||
| + | $ python setup.py install | ||
| - | Download latest version from source forge (version 1.1 in this case) | ||
| - | $ cd $MATPLOTLIB_FOLDER | ||
| - | $ python setup.py install | ||
| - | | ||
| - | === Scipy (minimal install) === | ||
| - | This requires that numpy already be installed and that LAPACK library are setup as in the numpy section. Before beginning the scipy installation, clear some possibly conflicting bash environmental variables | + | === Scipy, minimal install === |
| - | unset CPPFLAGS LDFLAGS | + | |
| - | + | ||
| - | Then | + | |
| $ 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/ | ||
| - | | + | $ python setup.py |
| - | | + | |
| - | Once the build has been successfully completed, its time to install | + | testing, |
| + | $ mkdir -p / | ||
| + | $ python setup.py | ||
| + | $ ipython | ||
| + | $ import os, sys | ||
| + | $ sys.path.insert(0,'/ | ||
| + | $ import scipy | ||
| + | $ scipy.test() | ||
| + | which did not work 100 % :( | ||
| + | FAILED (KNOWNFAIL=13, | ||
| + | Out[2]: < | ||
| + | |||
| + | If testing satisfactory, | ||
| + | $ rm -r /tmp/$USER/scipy-0.10.1_testing | ||
| $ python setup.py install | $ python setup.py install | ||
| - | $ cd ~ | + | ==== matplotlib / pylab ==== |
| - | $ python | + | |
| - | $ import scipy | + | |
| - | $ scipy.test() | + | |
| - | + | ||
| - | which did not work :( | + | |
| - | FAILED (KNOWNFAIL=13, SKIP=41, failures=2) | + | |
| - | Out[2]: < | + | |
| + | Download latest version from source forge (version 1.1 in this case) | ||
| + | $ cd $MATPLOTLIB_FOLDER | ||
| + | $ python setup.py install | ||
| | | ||