How do I use python-openbabel in Travis CI?

五迷三道 提交于 2020-01-03 12:07:50

问题


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?


回答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



回答2:


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



来源:https://stackoverflow.com/questions/22128856/how-do-i-use-python-openbabel-in-travis-ci

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!