From 8b29e174dea89b5c41c8a080129819e9226f1e59 Mon Sep 17 00:00:00 2001
From: Manuel Guenther <manuel.guenther@idiap.ch>
Date: Tue, 16 Dec 2014 11:25:12 +0100
Subject: [PATCH] Fixed issue when OpenCV library is not available.

---
 .travis.yml |  2 +-
 setup.py    | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index b7a9353..0c72656 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ before_install:
 - if [ -n "${NUMPYSPEC}" ]; then sudo apt-get install -qq --force-yes libatlas-dev libatlas-base-dev liblapack-dev gfortran; fi
 - if [ -n "${NUMPYSPEC}" ]; then pip install --upgrade pip setuptools; fi
 - if [ -n "${NUMPYSPEC}" ]; then pip install --find-links http://wheels.astropy.org/ --find-links http://wheels2.astropy.org/ --use-wheel numpy$NUMPYSPEC; fi
-- pip install --find-links http://wheels.astropy.org/ --find-links http://wheels2.astropy.org/ --use-wheel matplotlib==1.3.0 sphinx nose==1.3.0 jinja2==2.6 cpp-coveralls pygments==1.6 setuptools==7.0
+- pip install --find-links http://wheels.astropy.org/ --find-links http://wheels2.astropy.org/ --use-wheel matplotlib==1.3.0 sphinx nose==1.3.0 jinja2==2.6 cpp-coveralls pygments==1.6 setuptools==8.0
 install:
 - python bootstrap.py
 - CFLAGS=-coverage ./bin/buildout
diff --git a/setup.py b/setup.py
index 995b4d0..10b95c8 100644
--- a/setup.py
+++ b/setup.py
@@ -18,9 +18,18 @@ build_requires = load_requirements()
 # Define package version
 version = open("version.txt").read().rstrip()
 
-packages = ['boost', 'opencv>=2.0']
+packages = ['boost']
 boost_modules = ['system']
 
+# check if opencv is available
+try:
+  from bob.extension import check_packages
+  pkg = check_packages(['opencv>=2.0'])
+  print("Found OpenCV libraries %s" % pkg[0].libraries())
+  packages.append('opencv>=2.0')
+except RuntimeError as e:
+  print("OpenCV was not found, it will not be availabe during tests")
+
 setup(
 
     name="bob.ip.flandmark",
-- 
GitLab