Skip to content

Instantly share code, notes, and snippets.

@greglandrum
Last active March 16, 2023 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greglandrum/48e7662f4a38817b55d552d4a993f4d7 to your computer and use it in GitHub Desktop.
Save greglandrum/48e7662f4a38817b55d552d4a993f4d7 to your computer and use it in GitHub Desktop.

These instructions have been tested on linux and the Mac, both using the system C++ compilers. Note that you need a compiler which supports C++17.

Part 0: checkout RDKit github repo

git clone https://github.com/rdkit/rdkit.git RDKit_git

this will create a directory called RDKit_git with the RDKit source.

Part 1: setup conda environment

mamba create -n py310_rdkit_build python=3.10 boost-cpp boost cairo pandas pillow freetype cmake numpy eigen matplotlib 

Part 2: run cmake and build

from inside the RDKit source directory you checked out above:

conda activate py310_rdkit_build
mkdir build_demo
cd build_demo
cmake -DRDK_BUILD_INCHI_SUPPORT=ON -DRDK_BUILD_YAEHMOP_SUPPORT=ON -DRDK_BUILD_XYZ2MOL_SUPPORT=ON ..

That should run without errors. It’ll produce a bunch of warnings, but should end with something like:

-- Generating done
-- Build files have been written to: /localhome/glandrum/RDKit_git/build_demo

Now build it:

make -j8 install

That will take a while and generate a few warnings, but shouldn’t have any errors. The last line of the output should be something like this:

-- Installing: /localhome/glandrum/RDKit_git/rdkit/RDPaths.py

Part 3: setup your environment and then run the tests

Do this from inside the RDKit source directory (not the build directory). On linux:

export RDBASE=`pwd`
export PYTHONPATH=$RDBASE
export LD_LIBRARY_PATH=$RDBASE/lib:$CONDA_PREFIX/lib

on the Mac, that is:

export RDBASE=`pwd`
export PYTHONPATH=$RDBASE
export DYLD_LIBRARY_PATH=$RDBASE/lib:$CONDA_PREFIX/lib

Now you can run the tests:

cd build_demo
ctest -j6 –output-on-failure

This will take a bit and generate a lot of output, but the last bit should look something like this:

100% tests passed, 0 tests failed out of 219

Total Test time (real) =  63.92 sec

That’s it!

Part 4: Using the environment

In order to use the code you just need to repeat the export commands shown above. I find the following aliases really useful on linux:

alias remote_rdkit='unset RDBASE;export PYTHONPATH="";export LD_LIBRARY_PATH=""'
alias local_rdkit='conda activate py310_rdkit_build;export RDBASE="/localhome/glandrum/RDKit_git";export PYTHONPATH="$RDBASE";export LD_LIBRARY_PATH="$RDBASE/lib:$CONDA_PREFIX/lib"'
alias rdkit_vers='python -c "import rdkit;print(rdkit.__version__,rdkit.__file__)"'

local_rdkit sets up the shell to use my local RDKit build. remote_rdkit clears that stuff out so that you can use a conda rdkit install rdkit_vers shows you the current rdkit version and where the files are coming from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment