Subsections

3. Installing PLearn

The installation of PLearn consist of three phases: installing the dependensys of PLearn, configuring the environnement and we finish with the compilation of PLearn. The compilation is done with pymake witch use python. To have more information on pymake do: pymake help.

The next subsection discuss some other information about pymake that is cross-platform. After that their is sections that discuss the installation on linux, on Mac OS X and on windows with cygwin.

3.0.1 Cross-platform information about pymake

To have more information on pymake do: pymake help

To clean all the file generated during the compilation do pymake -clean [dir]. The dir parameter is optinal and if it is not there, the current directory will be used.

(Not sure this is cross-platform, tested on linux) If PLearn is on NFS(or other non local directory), you can speed up the recompilation+liniking, with the -tmp or the -local_ofiles options. Both will put the objects files in the local directory /tmp/.pymake instead of in the PLearn directory. This can considerably speed up the linking phase. The -tmp options will compile all the objects files only with the local host. When it is executed for the first time on a computer, it will compile all files. The next time, it will not recompile the previously compiled files if not needed. This is usefull is you have limited space on the PLearn directory on NFS, as there won't be any objects file in it, but if you move to another local computer, you must recompile everything.

The -local_ofiles option will distribute the compilation on many computer(see next paragraphe). When executed the first time, it will copy the objects files from the PLearn directory to the /tmp/.pymake directory. Then it will recompiles modified files and then link them in this directory. Finaly it will copy them in the PLearn directory. This way, if you change of computer, you won't need to recompile everything, but it will need more space in the PLearn directory. So the only advantage of -tmp over -local_ofiles is that it take less space in the directory of PLearn, but both will link at the same speed.

pymake support the compilation on multiple computer for faster compilation. The list of host is in a file in the directory /.pymake/. To know the name of the file run the compile command wanted. It will give you a line that look like this: (create a linux-i386.hosts file in your .pymake directory to list hosts for parallel compilation.) In this exemple, the file is linux-i386.hosts. On this file, you must put one host by line and those hosts most be of the same architecture that the one who start the compilation. If you want the computer that start the compilation to participate in the compiling, it must be included in the file.

The default compilation mode is in debug mode (-dbg). To use other mode, add it as a paramater to the compilation line like this: pymake -opt plearn_curses.cc. Here is the list of compilation mode:

3.1 Installation on Linux

3.1.1 PLearn setup and compilation

We suppose you have all the necessary software requirements in place (especially python).

For ex. under ubuntu, you can check the following packages install (using synaptic for ex.):

Required: g++, python2.4, python, libnspr4, libnspr-dev, libboost-dev, libboost-regex1.33.1, libboost-regex-dev, libboost-graph1.33.1, libboost-graph-dev
Strongly suggested: libncurses5, libncurses5-dev and some version of lapack and blas. Ex: refblas3, lapack3, lapack3-dev
Recommended (python and graphics related): ipython, python-matplotlib, python-numarray, python-numpy, mayavi, python2.4-dev, python-tk, python-gtk2, python-gtkhtml2

You can use the following command under an Ubuntu (probably other derivative of Debian) to install the required packages: sudo apt-get install g++ python2.4 python libnspr4 libnspr-dev libboost-dev libboost-regex1.33.1 libboost-regex-dev libboost-graph1.33.1 libboost-graph-dev. The following command for the strongly suggested packages: sudo apt-get install libncurses5 libncurses5-dev refblas3 lapack3 lapack3-dev. And the following command for the recommanded packages:sudo apt-get install ipython python-matplotlib python-numarray python-numpy mayavi python2.4-dev python-tk python-gtk2 python-gtkhtml2. The package that are alreay installed won't be reinstalled.

Then edit your .cshrc or .bashrc and

From within your PLearn directory run ./setup. This should create a .plearn sub-directory in your home directory, that will contain some configuration files.

Now you should be able to try and compile a first version of plearn. We have our own make system based on a python script (pymake) that automatically parses source files for dependencies and determines what to compile, and what to link (including optional libraries), and is able to run parallel compilation on several machines. It is easily customizable.

The compiling commands for the version with the minimum number of dependencies are:

cd PLearn/commands/
pymake -noblas plearn_noblas.cc

If it doesn't work, you may have to adapt the configuration file to your system (PLearn/.pymake/config)

If it does work, you can try with more dependencies to have more fonctionality with the commands pymake plearn_lapack.cc, pymake plearn\_curses.cc or even pymake plearn_python.cc

3.2 Installation on Mac OS X

3.2.1 External dependencies (Mac OS X 10.5 “Leopard”)

The easiest way to install external dependencies is through fink. You should install fink ( http://fink.sourceforge.net ) And its GUI Fink Commander ( http://finkcommander.sourceforge.net/ ). To gain access to the most up-to-date packages, enable the use of unstable package (e.g. in Menu Fink Commander / Preferences.../ Fink ). To be able to compile and link the core of plearn, you should install the following packages through fink:

Optional libraries also easily installable from fink:

3.2.2 External dependencies (older version of Mac OS X)

If you want to see graphical displays, you should also install X11 (apple has a version on its system install CDS shipped with the computers as part of XCode: look for packages X11 User and X11 SDK.

You should then install fink ( http://fink.sourceforge.net ) And its GUI Fink Commander ( http://finkcommander.sourceforge.net/ ). We recommend you also enable the use of unstable package (in Menu Fink Commander / Preferences.../ Fink ) to gain access to the latest packages.

To be able to compile and link the core of plearn, you should install the following packages through fink:

Optional libraries also easily installable from fink:

3.2.3 Environment setup

You should make sure the following variables and paths are correctly defined in your environment variables (in your .profile with your .bashrc simply doing a source $HOME/.profile)

# The default fink installs its packages in /sw and should already have
# added the following line.
source /sw/bin/init.sh

# adapt to your configuration if your PLearn directory is not $HOME/PLearn
export PLEARNDIR=$HOME/PLearn
export PATH=/sw/bin:/sw/sbin:$PLEARNDIR/scripts:$PLEARNDIR/commands:.:$PATH
export LD_LIBRARY_PATH="/sw/lib:/sw/lib/mozilla:$LD_LIBRARY_PATH"
export LIBRARY_PATH=$LD_LIBRARY_PATH
export CPATH="/sw/include:/sw/include/mozilla:$CPATH"
export PYTHONPATH="$PLEARNDIR/python_modules:$PLEARNDIR/scripts:$PYTHONPATH"
export SKELETONS_PATH=$PLEARNDIR/scripts/Skeletons

Restart a new shell for these to take effect. Make sure they're well defined in the new shell.

3.2.4 PLearn setup and compilation

From within your PLearn directory run ./setup. This should create a .plearn sub-directory in your home directory, that will contain some configuration files. The compiling commands for the version with the minimum number of dependencies are:

cd PLearn/commands/
pymake -noblas plearn_noblas.cc

If it doesn't work, you may have to adapt the configuration file to your system (PLearn/.pymake/config)

You can try with more dependencies to have more fonctionality with the commands pymake plearn_lapack.cc, pymake plearn_curses.cc or even pymake plearn_python.cc or pymake plearn_full.cc

To compile the plearn python extension module, do make_plearn_python_ext


3.3 Installation on Windows with cygwin

This section describes a step-by-step installation under the Microsoft Windows environment. Note that the following instructions are outdated.

Cygwin (http://cygwin.com) is a Linux-like environment for Windows, and is currently the easiest route to using PLearn under Windows.

3.3.1 Installing Cygwin

Download from http://cygwin.com/setup.exe the latest Cygwin setup program, then run it. Select your installation options (you should keep the recommended Unix / binary default text file type). Once you reach the “Select Packages” step, click the “View” button to switch to full view and select the following packages to install (the version number in parenthesis was the version used when this guide was written, hopefully any further version should work too).

Optional (but recommended) packages to install:

The default shell installed with Cygwin is bash, but in the following, we will be using tcsh (though you may of course adapt the instructions below to get PLearn to work with bash). Assuming you have installed the tcsh package and Cygwin is installed in C:\cygwin, edit C:\cygwin\cygwin.bat and replace the line bash --login -i with tcsh -l. You may also change the default location of your home directory by adding the following line at the beginning of the file (make sure you do not have blanks in the path you provide):

@SET HOME=C:\MyCygwinHome

Note that it is suggested to use a “low-level” path for your home directory, i.e. as close to the root as possible, because of the limitations of Windows concerning the length of paths (which may cause some tests to fail in the test-suite).

3.3.2 Installing Boost

The next step is to install the Boost library. You could install part of it from the Cygwin setup utility, but you would neeed to compile Boost-Python anyway. Go to http://sourceforge.net/projects/boost/ then to the “Files” section to download the Boost library. Download the tar.gz files: you will need the source for both Boost and Boost-Jam (the Boost installer). Move these files to your Cygwin home directory. The files used when writing this guide were boost_1_33_1.tar.gz and boost-jam-3.1.11.tgz.

You may now run Cygwin and launch the Boost installation:

  1. tar zxvf boost_1_33_1.tar.gz
  2. tar zxvf boost-jam-3.1.11.tgz
  3. cd boost-jam-3.1.11
  4. sh ./build.sh
  5. cd ../boost_1_33_1
  6. ../boost-jam-3.1.11/bin.cygwinx86/bjam.exe -sTOOLS=gcc
    --prefix=$HOME/local -sPYTHON_ROOT=/usr
    -sPYTHON_VERSION=2.4 --builddir=/tmp/boost_build install

The installation command above will install Boost in the local directory under your home directory: you may remove the --prefix option to perform a system-wide installation (however, installing under your home directory is often necessary for Linux users without administrator rights). Do not worry about some of the Boost libraries not compiling, PLearn does not need all of them. Let us just create the appropriate links for those needed by PLearn:

  1. cd ~/local/lib
  2. ln -s libboost_regex-gcc-mt-1_33_1.dll libboost_regex.dll
  3. ln -s libboost_python-gcc-mt-1_33_1.dll libboost_python.dll
  4. cd ~/local/include
  5. ln -s boost-1_33_1/boost

3.3.2.1 Installing NumArray

Download NumArray from
http://www.stsci.edu/resources/software_hardware/numarray
then install it with the following commands:

tar zxvf numarray-1.5.0.tar.gz
cd numarray-1.5.0
python setup.py config install --gencode --prefix=$HOME/local

Note that (at least in version 1.5.0) there is a typo in a NumArray C++ file. After you have installed NumArray with the commands above, edit ~/local/include/python2.4/numarray/arraybase.h to manually remove the comma at the end of line 117. Additionally, if you want to get rid of a gcc warning when compiling PLearn, you can edit libnumarray.h in the same directory and replace line 51 with

static void **libnumarray_API __attribute__ ((unused)) ;

3.3.3 Installing NSPR

Go to ftp://ftp.mozilla.org/pub/mozilla.org/nspr/releases to get the NSPR release for your operating system (in this guide we used the 4.6 release for Windows NT 5.0, in optimized mode). Extract the zip file to a temporary directory, then move the content of the include directory (including its sub-directories) to ~/local/include/mozilla/nspr (that you will need to create), and the libnspr4.dll file (in the lib directory) to ~/local/lib. Check the permissions for libnspr4.dll: you need the “execute” permission for PLearn to be able to run. You can set it with:
chmod u+x ~/local/lib/libnspr4.dll

3.3.4 Environment setup

First, go to the directory where you wish to install PLearn (in this guide we will assume this is your home directory), and check out the latest version from the Subversion repository:
svn checkout svn://svn.berlios.de/plearn/trunk PLearn

Since pymake will create directories named OBJS to store compiled object files, Subversion should ignore them: edit your ~/.subversion/config and, in the miscellany section, write the line
global-ignores = OBJS

Now, edit your ~/.cshrc and add the following lines:

# Environment variables.
setenv PLEARNDIR ${HOME}/PLearn
setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/lib/lapack:
            ${PLEARNDIR}/commands:${PLEARNDIR}/scripts:
            ${HOME}/local/lib
setenv PYTHONPATH ${PLEARNDIR}/python_modules:
                  ${HOME}/local/lib/python2.4/site-packages
setenv CPATH ${HOME}/local/include
setenv LD_LIBRARY_PATH ${HOME}/local/lib
setenv LIBRARY_PATH ${LD_LIBRARY_PATH}

# Nicer prompt.
set prompt = "%B%m %~%b > "

You need to redefine the PATH environment variable because the original one will usually contain directories with blanks (such as Program Files), which Cygwin has trouble with. The last line is very optional (it just gives you a nicer prompt). Now edit $PLEARNDIR/pymake.config.model and look for the python optional library. Just before, add the following lines:

python_version = '2.4'
compileflags += ' -DPL_PYTHON_VERSION=240'
python_lib_root = '/usr/lib'
numpy_site_packages = join(homedir,
              'local/lib/python2.4/site-packages/numarray')

Do a source ~/.cshrc to reload your configuration file, then go to your PLearn installation directory ($PLEARNDIR) and run ./setup. PLearn can now be compiled with pymake $PLEARNDIR/commands/plearn.