conda-openbabel on Windows

Posted on mån 15 april 2019 in Cheminformatics

I recently needed to use openbabel on Windows and decided to install it through conda since I use conda as my Python environment manager on that machine.

Installing openbabel, either by conda install -c openbabel openbabel or conda install -c conda-forge openbabel worked great and I proceded with my code. However, after a while I noticed that the InChI-format was missing from the install.

Going for Google and friends, there was some indications that this is a known problem with some efforts going into solving it.

But it still didn't work for me, so I set out to fix it.

Appveyour build failing

After cloning the repo and setting up AppVeyour, I immediately bumped inte the first problem. conda-build refused to work on AppVeyour, giving the error TypeError: LoadLibrary() argument 1 must be str, not None.

Further research showed that changes made in conda 3.16 made builds without prior activation of a conda environment fail. Apparently, the fact that it worked previously was not by design, but it meant that build settings that previously worked great stopped doing so with a rather crytic error message.

When the problem was found, solving it was as easy as adding the activate command to the install section in appveyour.yml.

Tests not failing

The second problem was that the tests in the conda recipe didn't fail, even when formats were missing, since obabel exits with the exit code 0 also when all conversion fails. An easy fix here was to grep for some specific text in the outputs instead and use that exit code to signal failure.

Actual InChI problem

Now I could finally fix the main problem. The build logs in AppVeyour included

WARNING: INCHI_LIBRARY not set, or does not exist.
....InChI format will NOT be compiled.

and looking in the cmake files it seemed to be due to these lines that forces the use of system InChI if OB_USE_PREBUILT_BINARIES is set on MSVC builds. Why this is so, and why the conda build is set to use prebuilt binaries, I don't know. But setting OB_USE_PREBUILT_BINARIES to OFF in the build instructions made everything work for me.

The changes have now been submitted as a PR, so we will see what happens.