1. Installation

Below are two currently available methods of installation.

Note

As of yet, the library is only available for the Linux platform and will only run on 64-bit systems. However, other platforms will probably be supported in the future as well.

Warning

The library has only been tested on a few Debian-based systems so far. Therefore, it might not work properly on other Linux distributions.

1.1. Installation with Anaconda

This is probably the easiest and preferred way to install the library and the associated Python package. All you need to do is either get the full Anaconda distribution or its lightweight variant, Miniconda.

Anaconda/Miniconda is essentially a Python distribution, package manager and virtual environment in one and makes setting up a development environment for your project very easy. After installing Anaconda/Miniconda you need to run the following to install the package:

conda install -c lich molpher-lib

This will automatically install the latest non-development version of the library in the currently active environment (for more information on environments and the conda command see Conda Test Drive).

1.2. Building and Installing from Source – Linux

If you want to build the source code yourself, you will have to use cmake. This section describes how to do that on the Linux platform. If you want to build the library on a different platform, this section might provide useful information as well. However, you might need to make some adjustments to the underlying CMakeLists.txt file and build and link the dependencies yourself.

Note

If you manage to successfully build the library on a platform other than Linux, please, consider making a pull request and contributing your code to the official GitHub repository.

You can get the source code with the following command:

git clone https://github.com/lich-uct/molpher-lib.git

1.2.1. Prerequisites

Before you start building, there are a few requirements that need to be satisfied:

  • build-essential – You will need this package in order to be able to build software on most Linux platforms. It contains a compiler and other tools important for the build.

  • swig – It is used to generate the Python wrapping code (we are using version 3.0.10 at the moment).

    SWIG is only required if you made changes to the interface (header files under include/) and want to configure cmake with the -DRUN_SWIG=ON option (see the description of the molpher_build_SWIG_Python target in the section below). If this option is turned on, SWIG will be invoked by make upon build with the swig3.0 command so make sure the SWIG executable is available in the working environment.

  • setuptools – This Python package is needed to install the associated Python code.

  • python{version}-dev – You will need this package to build Python bindings for your Python version.

    If you get ‘Missing Python.h’ compiler errors, you probably do not have this package installed.

  • dependencies – Molpher-lib depends on three third-party libraries:

    • boost (1.50.0)
    • rdkit (2014.03.1)
    • tbb (4.2)

    You can build the individual dependencies yourself and place them in the deps/ folder in the repository root. For each dependency, there should be a folder of the same name under deps/ (for example, the path to the tbb files would be deps/tbb/). The cmake build script will automatically identify and prioritize dependencies in this directory. However, there is a build script (deps/build_deps.sh) which can download and build the libraries automatically. Therefore, it should be sufficient to do:

    ./build_deps.sh --all
    

    You can also install the libraries on your system using a package manager or other means. In that case, cmake will automatically try to find them and link them during the build. Please, note that the build system is configured so that only static libraries of boost and rdkit are recognized. If you wish to link dynamically, you will need to modify the CMakeLists.txt file accordingly.

1.2.2. Building the Library

When the above requirements are met, you can start building. First, you need to initialize the cmake project from a build directory:

mkdir ${REPOSITORY_ROOT}/cmake_dir/ # create a subdirectory in the root of the repository
cd ${REPOSITORY_ROOT}/cmake_dir/
cmake .. # initialize the project

At this point, cmake checks the dependencies and generates the main makefile which defines three important targets:

  1. molpher – This is the main target. It builds the C++ source code of the library and creates all necessary binary files. All targets mentioned below depend on this target.

  2. molpher_install – This target will install the library in the given location.

    By default, this location is the dist/ folder in the repository root. This can be changed when the cmake project is initialized by setting CMAKE_INSTALL_PREFIX. Also by default, the TBB library is installed along with the molpher-lib files, because it is also a runtime dependency. If you do not want this behaviour you can instruct cmake to omit the installation of TBB with the -DINSTALL_TBB=OFF option.

  3. molpher_install_python – This will install the Python package and the C++ extensions using the generated SWIG wrapper code.

    By default, the primary Python distribution on the system is used. You can specify a different executable by specifying the path with -DPYTHON_EXECUTABLE when you run cmake.

    If you want to update the SWIG wrapping code before this target is run, you can instruct cmake to do so with the -DRUN_SWIG=ON option.

    When this target finishes, all required files should be in place and you should be able to import the molpher Python package located under src/python/. Just add this directory to your PYTHONPATH variable and it should work.

    Note

    You can also use the package created under CMAKE_INSTALL_PREFIX. In this case, you need to have the following variables set up:

    PYTHONPATH=$CMAKE_INSTALL_PREFIX/lib/pythonX.Y/site-packages # replace X.Y with your Python version
    LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib
    

The build of a given configuration is initialized from the cmake project directory as:

make $CONFIG # CONFIG is a configurations' name

1.2.3. Building Conda Packages

If you want to build your own conda packages, you can use a python script located in conda/ subdirectory of the repository root:

cd ${REPOSITORY_ROOT}/conda
python build_conda.py

Attention

You will need conda-build and the jinja2 Python library to do that.

You can install the built packages as follows:

conda install --use-local molpher-lib

1.2.4. Building the Documentation

This documentation is generated using the build_docs.sh script under the doc/ directory. However, in order to successfully build the documentation you will need a few packages in your Python environment:

Listing 1.1 The conda environment file used to build the documentation and test the library.
name: molpher-lib-docs
channels:
- rdkit
- omnia
- defaults
dependencies:
- bzip2=1.0.6=3
- mkl=11.3.3=0
- numpy=1.11.1=py35_0
- openssl=1.0.2h=1
- pip=8.1.2=py35_0
- psutil=4.3.0=py35_0
- python=3.5.1=0
- boost=1.56.0=py35_3
- rdkit=2016.03.2=np111py35_1
- readline=6.2=2
- setuptools=23.0.0=py35_0
- sqlite=3.13.0=0
- tk=8.5.18=0
- wheel=0.29.0=py35_0
- xz=5.0.5=1
- zlib=1.2.8=3
- doxygen
- pip:
  - alabaster==0.7.7
  - babel==2.3.3
  - breathe==4.2.0
  - docutils==0.12
  - imagesize==0.7.0
  - jinja2==2.8
  - markupsafe==0.23
  - pygments==2.1.3
  - pytz==2016.3
  - six==1.10.0
  - snowballstemmer==1.2.1
  - sphinx==1.4.1
  - sphinx-rtd-theme==0.1.9

You can easily install all these packages like so:

conda env create -n molpher-lib-docs -f environment.yml

Also, make sure you initialized the Python package (built the molpher_install_python target as described above) prior to generating the documentation so that Sphinx can successfully import the molpher package.

To update the GitHub pages with the current version of the documentation, you can simply run the build_docs.sh with the `--upload` option:

build_docs.sh --upload

Note

You will need write access to the repository and an SSH key attached to your account to be able to upload the documentation.