Skip to content

Installation

amelie edited this page Jun 27, 2024 · 17 revisions

Installing the python bindings on Linux

The easiest is to install the latest release of the package using pip, which comes with precompiled binaries so no non-python dependencies are required:

pip install titanlib

To check that the installation worked, run the following in python:

import titanlib
print(titanlib.version())

Full titanlib installation from source

Installation

1) Download source code

Either download the source code from the latest release, unzip the file and navigate into the extracted folder; or clone the repo from github.

1) Install dependencies

On Ubuntu Bionic

These can be installed like this:

sudo apt-get update
sudo apt-get install libboost-all-dev
sudo apt-get install libgsl-dev libblas-dev
sudo apt install swig cmake
sudo apt-get install doxygen

In a conda environment

The dependencies can alternatively be installed in a conda environment. To do so, use the deps.yml file contained in titanlib and type:

conda env create --file=deps.yml

This will create a conda environment named condatitanlib. Then activate this conda environment using:

conda activate condatitanlib

The command to quit this environment is:

conda deactivate

3) Set up cmake installation

mkdir build
cd build
cmake ..

Example of useful options for cmake :

Install the library in a different directory

If you don't have sudo rights or want to install the library in a different directory, you can add the following argument to the cmake command :

-DCMAKE_INSTALL_PREFIX=your_directory_here

Replace your_directory_here with the desired installation path.

Installation without R-binding:

Use the cmake command with:

-DBUILD_R=OFF
Installation using debug/release compilation options:

Debug or release compilations options are available. The option changes the compilations flags. Use the cmake command with:

-DCMAKE_BUILD_TYPE=RELEASE -B ./release

or

-DCMAKE_BUILD_TYPE=BEBUG -B ./debug

-B creates the build repertory (so step 3 and 4 can be done in once):

Then continue the installation from the chosen build repertory.

4) Install the C++ library

sudo make install

This will install the library in /usr/local/lib/libtitanlib.so or in your chosen repertory if -DCMAKE_INSTALL_PREFIX was used as cmake option.

5) Install the python bindings

Installation is tested for instance with Python 3.10.4.

make install-python-user -j 8

This installs the python bindings in ~/local/lib/python3.6/site-packages/titanlib.py. To install the python bindings system-wide, use sudo make install-python instead.

It is possible to compile in parallel using the option -j N, where N is the number of workers (see https://docs.python.org/3/library/compileall.html).

6) Install the R bindings

make build-r

Currently, the R package is not installed centrally, but instead is placed in build/swig/R/titanlib.R where you also have titanlib.so.