From 14d544adadef9ba708a30d5132e9788de13631df Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.anjos@idiap.ch>
Date: Tue, 20 May 2014 14:59:41 +0200
Subject: [PATCH] Upgrade to discrete xbob.io packages

---
 buildout.cfg                    |  8 +++++---
 setup.py                        |  9 +++++----
 xbob/ip/flandmark/flandmark.cpp |  2 +-
 xbob/ip/flandmark/main.cpp      | 17 +++++++++++++----
 xbob/ip/flandmark/test.py       | 11 ++++++-----
 xbob/ip/flandmark/version.cpp   |  8 ++++----
 6 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/buildout.cfg b/buildout.cfg
index 6eb656b..f889ced 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -10,7 +10,8 @@ extensions = xbob.buildout
 auto-checkout = *
 develop = src/xbob.extension
           src/xbob.blitz
-          src/xbob.io
+          src/xbob.io.base
+          src/xbob.io.image
           src/xbob.ip.color
           src/xbob.ip.draw
           .
@@ -18,13 +19,14 @@ develop = src/xbob.extension
 ; options for xbob.buildout extension
 debug = true
 verbose = true
-prefixes = /idiap/group/torch5spro/nightlies/last/bob/linux-x86_64-release
+prefixes = /idiap/group/torch5spro/releases/preview/install/linux-x86_64-release
            /Users/andre/work/bob/b/dbg/
 
 [sources]
 xbob.extension = git https://github.com/bioidiap/xbob.extension branch=prototype
 xbob.blitz = git https://github.com/bioidiap/xbob.blitz
-xbob.io = git https://github.com/bioidiap/xbob.io
+xbob.io.base = git https://github.com/bioidiap/xbob.io.base
+xbob.io.image = git https://github.com/bioidiap/xbob.io.image
 xbob.ip.color = git https://github.com/bioidiap/xbob.ip.color
 xbob.ip.draw = git https://github.com/bioidiap/xbob.ip.draw
 
diff --git a/setup.py b/setup.py
index 529124c..84721de 100644
--- a/setup.py
+++ b/setup.py
@@ -7,14 +7,14 @@
 """
 
 from setuptools import setup, find_packages, dist
-dist.Distribution(dict(setup_requires=['xbob.blitz', 'xbob.io']))
+dist.Distribution(dict(setup_requires=['xbob.blitz', 'xbob.io.base']))
 from xbob.blitz.extension import Extension
-import xbob.io
+import xbob.io.base
 
 version = '2.0.0a0'
 packages = ['boost', 'opencv>=2.0', 'bob-io>=1.2.2']
 
-include_dirs = [xbob.io.get_include()]
+include_dirs = [xbob.io.base.get_include()]
 
 setup(
 
@@ -34,7 +34,8 @@ setup(
     install_requires=[
       'setuptools',
       'xbob.blitz',
-      'xbob.io', #for tests
+      'xbob.io.base',
+      'xbob.io.image', #for tests
       'xbob.ip.color', #for tests
       'xbob.ip.draw', #for doc generation
       'matplotlib', #for doc generation
diff --git a/xbob/ip/flandmark/flandmark.cpp b/xbob/ip/flandmark/flandmark.cpp
index 299fb7a..5a49ee6 100644
--- a/xbob/ip/flandmark/flandmark.cpp
+++ b/xbob/ip/flandmark/flandmark.cpp
@@ -7,7 +7,7 @@
 
 #include <xbob.blitz/cppapi.h>
 #include <xbob.blitz/cleanup.h>
-#include <xbob.io/api.h>
+#include <xbob.io.base/api.h>
 #include <structmember.h>
 
 #include <xbob.extension/documentation.h>
diff --git a/xbob/ip/flandmark/main.cpp b/xbob/ip/flandmark/main.cpp
index fedd774..2aed675 100644
--- a/xbob/ip/flandmark/main.cpp
+++ b/xbob/ip/flandmark/main.cpp
@@ -10,7 +10,7 @@
 #endif
 #include <xbob.blitz/capi.h>
 #include <xbob.blitz/cleanup.h>
-#include <xbob.io/api.h>
+#include <xbob.io.base/api.h>
 #include <xbob.extension/documentation.h>
 
 extern PyTypeObject PyBobIpFlandmark_Type;
@@ -81,9 +81,18 @@ static PyObject* create_module (void) {
   Py_INCREF(&PyBobIpFlandmark_Type);
   if (PyModule_AddObject(m, "Flandmark", (PyObject *)&PyBobIpFlandmark_Type) < 0) return 0;
 
-  /* imports xbob.blitz C-API + dependencies */
-  if (import_xbob_blitz() < 0) return 0;
-  if (import_xbob_io() < 0) return 0;
+  /* imports dependencies */
+  if (import_xbob_blitz() < 0) {
+    PyErr_Print();
+    PyErr_Format(PyExc_ImportError, "cannot import `%s'", XBOB_EXT_MODULE_NAME);
+    return 0;
+  }
+
+  if (import_xbob_io_base() < 0) {
+    PyErr_Print();
+    PyErr_Format(PyExc_ImportError, "cannot import `%s'", XBOB_EXT_MODULE_NAME);
+    return 0;
+  }
 
   Py_INCREF(m);
   return m;
diff --git a/xbob/ip/flandmark/test.py b/xbob/ip/flandmark/test.py
index 4822ab5..c7d203c 100644
--- a/xbob/ip/flandmark/test.py
+++ b/xbob/ip/flandmark/test.py
@@ -11,7 +11,8 @@ import numpy
 import functools
 import pkg_resources
 import nose.tools
-import xbob.io
+import xbob.io.base
+import xbob.io.image
 import xbob.ip.color
 
 from . import Flandmark
@@ -119,7 +120,7 @@ def test_is_outside():
 @opencv_available
 def test_lena_opencv():
 
-  img = xbob.io.load(LENA)
+  img = xbob.io.base.load(LENA)
   gray = xbob.ip.color.rgb_to_gray(img)
   (x, y, width, height) = opencv_detect(gray)[0]
 
@@ -132,7 +133,7 @@ def test_lena_opencv():
 
 def test_lena():
 
-  img = xbob.io.load(LENA)
+  img = xbob.io.base.load(LENA)
   gray = xbob.ip.color.rgb_to_gray(img)
   (x, y, width, height) = LENA_BBX[0]
 
@@ -146,7 +147,7 @@ def test_lena():
 @opencv_available
 def test_multi_opencv():
 
-  img = xbob.io.load(MULTI)
+  img = xbob.io.base.load(MULTI)
   gray = xbob.ip.color.rgb_to_gray(img)
   bbx = opencv_detect(gray)
 
@@ -160,7 +161,7 @@ def test_multi_opencv():
 
 def test_multi():
 
-  img = xbob.io.load(MULTI)
+  img = xbob.io.base.load(MULTI)
   gray = xbob.ip.color.rgb_to_gray(img)
 
   flm = Flandmark()
diff --git a/xbob/ip/flandmark/version.cpp b/xbob/ip/flandmark/version.cpp
index 364d341..d130894 100644
--- a/xbob/ip/flandmark/version.cpp
+++ b/xbob/ip/flandmark/version.cpp
@@ -20,7 +20,7 @@
 #endif
 #include <xbob.blitz/capi.h>
 #include <xbob.blitz/cleanup.h>
-#include <xbob.io/config.h>
+#include <xbob.io.base/config.h>
 
 static int dict_set(PyObject* d, const char* key, const char* value) {
   PyObject* v = Py_BuildValue("s", value);
@@ -98,8 +98,8 @@ static PyObject* xbob_blitz_version() {
 /**
  * xbob.io c/c++ api version
  */
-static PyObject* xbob_io_version() {
-  return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(XBOB_IO_API_VERSION));
+static PyObject* xbob_io_base_version() {
+  return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(XBOB_IO_BASE_API_VERSION));
 }
 
 static PyObject* build_version_dictionary() {
@@ -115,7 +115,7 @@ static PyObject* build_version_dictionary() {
   if (!dict_steal(retval, "Python", python_version())) return 0;
   if (!dict_steal(retval, "NumPy", numpy_version())) return 0;
   if (!dict_steal(retval, "xbob.blitz", xbob_blitz_version())) return 0;
-  if (!dict_steal(retval, "xbob.io", xbob_io_version())) return 0;
+  if (!dict_steal(retval, "xbob.io", xbob_io_base_version())) return 0;
 
   Py_INCREF(retval);
   return retval;
-- 
GitLab