Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use python-openbabel in Travis CI?

I use Travis CI as part of a Toxicology mapping project. For this project I require python-openbabel as a dependency. As such, I have added the apt-get installer to the .travis.yml file, shown below ( comments removed ).

language: python
python: 
  - "2.7"
before_install:
  - sudo apt-get update -qq
  - sudo apt-get install python-openbabel
install: "pip install -r requirements.txt"
script: nosetests tox.py

However, all these attempts failed with the error message Error: SWIG failed. Is Open Babel installed?. I have tried adding SWIG to the list of applications to be installed, to no avail.

Additionally, I have attempted to add the entire build process as proposed by Openbabel itself, this yields the following travis.yml:

language: python
python: 
  - "2.7"
before_install:
  - sudo apt-get update -qq
  - sudo apt-get install python-openbabel
  - wget http://downloads.sourceforge.net/project/openbabel/openbabel/2.3.1/openbabel-2.3.1.tar.gz?r=http://%3A%2F%2Fsourceforge.net%2Fprojects%2Fopenbabel%2Fopenbabel%2F2.3.1%2Fts=1393727248&use_mirror=switch
  - tar zxf openbabel-2.3.1.tar.gz
  - mkdir build
  - cd build
  - cmake ../openbabel-2.3.1 -DPYTHON_BINDINGS=ON
  - make
  - make install
  - export PYTHONPATH=/usr/local/lib:$PYTHONPATH
install: "pip install -r requirements.txt"
script: nosetests tox.py

This fails when trying to untar the downloaded file.

All the failed builds can be seen on Travis-CI: https://travis-ci.org/ToxProject/ToxProject
The Github repo is here: https://github.com/ToxProject/ToxProject

In short, how do I get python-openbabel working with Travis-CI?

like image 662
Stephan Heijl Avatar asked Nov 01 '22 04:11

Stephan Heijl


1 Answers

The version of openbabel installed via apt-get is 1.7 while the version specified in setup.py in requirements.txt is openbabel>=1.8. This make makes the package installed by apt-get not satisfy the requirements.txt and pip is trying install it regardless the installed old version of openbabel. And virtualenv doesn't use the already installed system packages.

And when install openbabel via pip, it needs the header files of libopenbabel which is not included in libopenbabel4 which is automatically installed by python-openbabel The version of libopenbabel-dev in ubuntu 12.04 used by travisCI doesn't satisfy the needs of openbabel==1.8.

Solution:

install newer version of libopenbabel-dev and libopenbabel4 manually:

before_install:
  - sudo apt-get install -qq -y swig python-dev
  - wget http://mirrors.kernel.org/ubuntu/pool/universe/o/openbabel/libopenbabel4_2.3.2+dfsg-1.1_amd64.deb
  - sudo dpkg -i libopenbabel4_2.3.2+dfsg-1.1_amd64.deb
  - wget http://mirrors.kernel.org/ubuntu/pool/universe/o/openbabel/libopenbabel-dev_2.3.2+dfsg-1.1_amd64.deb
  - sudo dpkg -i libopenbabel-dev_2.3.2+dfsg-1.1_amd64.deb
like image 112
Binux Avatar answered Nov 15 '22 06:11

Binux