Skip to content

Latest commit

 

History

History
276 lines (154 loc) · 5.86 KB

install.rst

File metadata and controls

276 lines (154 loc) · 5.86 KB

Installing gtpsa-cpp

gtpsa-cpp consists of a c++ library and python wrapper to it. Here it is first described how to build the library and then how to build the python wrapper.

Dependencies

  • modern c++ compiler C++17 or better

    • std::shared_ptr
    • std::variant
  • modern fortran compiler for building some subparts of mad-ng

  • cmake

  • pybind 11

  • armadillo matrix library

  • modern python3

Packages to be installed on Ubuntu 22 LTS

Install packages that could be missing for the c++ library

sudo apt-get install bison flex cmake g++ gfortran libarmadillo-dev libboost-all-dev

The following packages could be missing for the python wrapper

sudo apt-get install bison flex cmake g++ gfortran libarmadillo-dev libboost-all-dev pybind11-dev python3-pandas

Checking out repository

First clone the repository using

git clone https://github.com/hz-b/gtpsa-cpp.git

change to the directory (persumably) gtpsa-cpp.

Then initialise submodules using the following command

git submodule update --init

Currently the sole external repository is mad-ng.

Getting ready to build

create a directory "build"

mkdir build

then change to this directory

cd build

then in this directory execute

cmake ..

This will create the build file. Typically this is a make file. In case the cmake command fails, please remove at least the CMakeCache.txt file in the build directory. If this steps fails, find some hints how to solve them in section "Helping CMAKE find subcomponents" :ref:`cmake-find-subcomponents`. When cmake worked, trigger the build. In case you use make type

make

The build can be verified executing the tests using

make test

If build was successful use

cmake --install . --prefix /path/to/install/to

with /path/to/install/to the absolute path of the directory you would like to install to.

NB: The libaries implementing the python interface will be currently installed in the source tree into directory python/thor_scsi and src/gtpsa/python. Have a look below for details of loading dynamic objects from non standard directories if you want to use these. The python wrapper and module can be installed using setup.py too.

Installing python module

Currently the python wrapper is automatically built when the c++ library is built. Additionally a setup.py script is provided that can be used to use the standard python install procedure.

Before you can use this script, you need to build the c++ library and install it
to some path (called /path/to/install/to above).

The process of building the python package depends on the C++ headers and libraries. Thus it needs to know where these are installed. The process described below will use the directory provided by the environment variable:

  • gtpsa_PREFIX

Change into the repositories python directory. Make sure that the environment variable is set so that the path is included that gtpsa header and library files are located e.g.: by specifiying

export gtpsa_PREFIX=path/to/install/to

As soon that has been done, you should be able to use e.g.

python setup.py build

to build the module and

python setup.py install

to install the module.

Alternatively you could use pip e.g.

pip install .

to install the package.

If you are curios how and where to get pip see the link below.

https://pip.pypa.io/en/stable/installation/

Helping CMAKE find subcomponents

Here some information if cmake above fails.

Cmake checks that the version of required subcomponents is sufficient. If it reports that one of the components is not sufficiently new, I recommend to follow the following steps:

  1. follow the instructions below required to make camke identify the component
  2. After the cmake found the components I recommend to
    1. remove the build directory
    2. create a new build directory
    3. run cmake in this clean directory.

Reason: cmake stores cache files and directories in the build directory. These can still information from former cmake runs. In my experience some rather strange configuration / build problems are cured in this manner.

Up to date pybind11

If your version pybind 11 is rejected by cmake:

  1. install it using pip

    pip3 install pybind11

    it can be that you have to use the --user flag so that it is installed within your environment.

  2. help cmake find the installation. E.g. for a local installation on ubuntu (focal) it is typically found at

    ls -d  $HOME/.local/lib/python3.8/site-packages/pybind11

    If still an too old version of pybind11 is found, please set the environment variable pybind11_DIR to the correct directory

    e.g.

    export pybind11_DIR=$HOME/.local/lib/python3.8/site-packages/pybind11

Loading dynamic objects from non standard locations

The libraries of gtpsa-cpp or the libraries for the python interface can be installed in non standard places.

Linux

One solution can be to define the directory in LD_LIBRARY_PATH e.g.:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/install/to/lib/

MAC OS

One solution can be to define the directory in LD_LIBRARY_PATH e.g.:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/path/to/install/to/lib/

Documentation

Documentation can be built by the user. Requirements

  • doxygen
  • sphinx-doc
  • breathe
  • exhale