5

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?

Stephan Heijl
  • 464
  • 6
  • 19
  • Where are the dependencies installed if you run the installation of openbabel on your machine? – User Mar 02 '14 at 20:32
  • Yes, using `sudo apt-get install python-openbabel` was all that was required for use on my machine, running Ubuntu Server 12.04. – Stephan Heijl Mar 02 '14 at 21:27

2 Answers2

1

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
Binux
  • 697
  • 6
  • 12
  • While I can't speak to whether or not this solved the problem for the OP, it doesn't for me. Everything works fine (it says it can find the openbabel stuff) until it gets to [`stereo.i:6: Error: Unable to find 'openbabel/stereo/bindings.h'`](https://travis-ci.org/Dannnno/Chemistry/jobs/49558444). – Dan Oberlam Feb 05 '15 at 06:08
  • 1
    @Dannnno that's my fault, I test it in a ubuntu 14.04 box but 12.04. I have updated the answer. And for pypy, it's another problem: https://bitbucket.org/pypy/pypy/issue/1382/ – Binux Feb 05 '15 at 09:05
  • Awesome, that appears to fix it. Currently I'm including `sudo apt-get install -y python-openbabel` in the `before_install` section, as well as `pip install openbabel` in the `install` section. Do I need both, or will one suffice? – Dan Oberlam Feb 05 '15 at 09:22
  • 1
    The `pip` is enough (if `openbabel` is in requirements.txt, the command is unnecessary). `apt-get install -y python-openbabel` may not work as virtualenv doesn't use system packages (or try grasshopper's solution). – Binux Feb 05 '15 at 09:47
  • Thanks for your help. Barring any issues that appear, I'll award you the bounty when the timer lets me. – Dan Oberlam Feb 05 '15 at 18:08
1

I see that now the build fails at the pip install requirements stage. Travis creates a virtual environment for running python. By default, python packages installed on the system (ie via apt-get) will not be available, unless you add this to your travils.yml:

virtualenv:
      system_site_packages: true

I had the same problem with python-qt4 and python-qgis, here is a travis.yml file I used recently: https://github.com/anitagraser/TimeManager/blob/master/.travis.yml

grasshopper
  • 3,988
  • 3
  • 23
  • 29