From 9a397e510a2a55a1d45ef77ffd38ffc739a0433a Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.dos.anjos@gmail.com>
Date: Mon, 18 Nov 2013 23:12:17 +0100
Subject: [PATCH] Depends on xbob.blitz for config

---
 setup.py                | 92 ++++++-----------------------------------
 src/xbob.blitz          |  2 +-
 xbob/io/bobskin.cpp     |  2 +-
 xbob/io/bobskin.h       |  2 +-
 xbob/io/externals.cpp   |  2 +-
 xbob/io/file.cpp        | 12 +++---
 xbob/io/hdf5.cpp        | 14 +++----
 xbob/io/main.cpp        |  8 ++--
 xbob/io/videoreader.cpp |  4 +-
 xbob/io/videowriter.cpp |  4 +-
 10 files changed, 37 insertions(+), 105 deletions(-)

diff --git a/setup.py b/setup.py
index beddbcf..ba5d5b8 100644
--- a/setup.py
+++ b/setup.py
@@ -4,77 +4,17 @@
 # Mon 16 Apr 08:18:08 2012 CEST
 
 from setuptools import setup, find_packages, dist
-dist.Distribution(dict(setup_requires=['numpy', 'xbob.extension']))
-import numpy
-from xbob.extension import Extension
-from setuptools import setup, find_packages, dist
-from distutils.extension import Extension
-from distutils.version import LooseVersion
-
-dist.Distribution(dict(setup_requires=['pypkg', 'numpy', 'blitz.array']))
-import pypkg
-import numpy
-import blitz
-import platform
-
-# Minimum version requirements for pkg-config packages
-MINIMAL_BLITZ_VERSION_REQUIRED = '0.10'
-MINIMAL_BOB_VERSION_REQUIRED = '1.3'
-
-# Pkg-config dependencies
-blitz_pkg = pypkg.pkgconfig('blitz')
-if blitz_pkg < MINIMAL_BLITZ_VERSION_REQUIRED:
-  raise RuntimeError("This package requires Blitz++ %s or superior, but you have %s" % (MINIMAL_BLITZ_VERSION_REQUIRED, blitz_pkg.version))
-
-bob_pkg = pypkg.pkgconfig('bob-io')
-if bob_pkg < MINIMAL_BOB_VERSION_REQUIRED:
-  raise RuntimeError("This package requires Bob %s or superior, but you have %s" % (MINIMAL_BOB_VERSION_REQUIRED, bob_pkg.version))
-
-# Make-up the names of versioned Bob libraries we must link against
-if platform.system() == 'Darwin':
-  bob_libraries=['%s.%s' % (k, bob_pkg.version) for k in bob_pkg.libraries()]
-elif platform.system() == 'Linux':
-  bob_libraries=[':lib%s.so.%s' % (k, bob_pkg.version) for k in bob_pkg.libraries()]
-else:
-  raise RuntimeError("This package currently only supports MacOSX and Linux builds")
-
-# Add system include directories
-extra_compile_args = []
-system_includes = \
-    [blitz.get_include()] + \
-    blitz_pkg.include_directories() + \
-    [numpy.get_include()]
-for k in system_includes: extra_compile_args += ['-isystem', k]
-
-# NumPy API macros necessary?
-define_macros=[
-    ("PY_ARRAY_UNIQUE_SYMBOL", "XBOB_IO_PY_ARRAY_API"),
-    ("NO_IMPORT_ARRAY", "1"),
-    ]
-
-import numpy
-from distutils.version import StrictVersion
-if StrictVersion(numpy.__version__) >= StrictVersion('1.7'):
-  define_macros.append(("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"))
-
-# Compilation options
-if platform.system() == 'Darwin':
-  extra_compile_args += ['-std=c++11', '-Wno-#warnings']
-else:
-  extra_compile_args += ['-std=c++11']
+dist.Distribution(dict(setup_requires=['xbob.blitz']))
+from xbob.blitz.extension import Extension
 
-# Local include directory
 import os
 package_dir = os.path.dirname(os.path.realpath(__file__))
-package_base = os.path.join(package_dir, 'xbob', 'io')
 package_dir = os.path.join(package_dir, 'xbob', 'io', 'include')
-include_dirs = [package_base, package_dir]
+include_dirs = [package_dir]
 
-# Define package version
+packages = ['bob-io >= 1.3']
 version = '2.0.0a0'
-define_macros += [
-    ("XBOB_IO_VERSION", version),
-    ]
+define_macros = [("XBOB_IO_VERSION", '"%s"' % version)]
 
 setup(
 
@@ -93,7 +33,7 @@ setup(
 
     install_requires=[
       'setuptools',
-      'blitz.array',
+      'xbob.blitz',
     ],
 
     namespace_packages=[
@@ -105,13 +45,9 @@ setup(
         [
           "xbob/io/externals.cpp",
           ],
-        define_macros=define_macros,
-        include_dirs=include_dirs,
-        extra_compile_args=extra_compile_args,
-        library_dirs=bob_pkg.library_directories(),
-        runtime_library_dirs=bob_pkg.library_directories(),
-        libraries=bob_libraries,
-        language="c++",
+        packages = packages,
+        define_macros = define_macros,
+        include_dirs = include_dirs,
         ),
       Extension("xbob.io._library",
         [
@@ -122,13 +58,9 @@ setup(
           "xbob/io/hdf5.cpp",
           "xbob/io/main.cpp",
           ],
-        define_macros=define_macros,
-        include_dirs=include_dirs + bob_pkg.include_directories(),
-        extra_compile_args=extra_compile_args,
-        library_dirs=bob_pkg.library_directories(),
-        runtime_library_dirs=bob_pkg.library_directories(),
-        libraries=bob_libraries,
-        language="c++",
+        packages = packages,
+        define_macros = define_macros,
+        include_dirs = include_dirs,
         ),
       ],
 
diff --git a/src/xbob.blitz b/src/xbob.blitz
index 6162b26..3d44730 160000
--- a/src/xbob.blitz
+++ b/src/xbob.blitz
@@ -1 +1 @@
-Subproject commit 6162b2623dcee7b7570cd0462ed5baec20320162
+Subproject commit 3d4473033ba5304b1b8399019ad055abd3d1f057
diff --git a/xbob/io/bobskin.cpp b/xbob/io/bobskin.cpp
index ec30147..603df51 100644
--- a/xbob/io/bobskin.cpp
+++ b/xbob/io/bobskin.cpp
@@ -5,8 +5,8 @@
  * @brief Implementation of our bobskin class
  */
 
-#include <bobskin.h>
 #include <stdexcept>
+#include "bobskin.h"
 
 bobskin::bobskin(PyObject* array, bob::core::array::ElementType eltype) {
 
diff --git a/xbob/io/bobskin.h b/xbob/io/bobskin.h
index 8a9fe7b..bdae7b6 100644
--- a/xbob/io/bobskin.h
+++ b/xbob/io/bobskin.h
@@ -10,7 +10,7 @@
 
 extern "C" {
 #include <Python.h>
-#include <blitz.array/capi.h>
+#include <xbob.blitz/capi.h>
 }
 
 
diff --git a/xbob/io/externals.cpp b/xbob/io/externals.cpp
index 73fb7ce..af24381 100644
--- a/xbob/io/externals.cpp
+++ b/xbob/io/externals.cpp
@@ -950,7 +950,7 @@ PyMODINIT_FUNC ENTRY_FUNCTION(XBOB_IO_VERSIONS_MODULE_NAME) (void) {
 
   /* register some constants */
   PyModule_AddIntConstant(m, "__api_version__", XBOB_IO_API_VERSION);
-  PyModule_AddStringConstant(m, "__version__", BOOST_PP_STRINGIZE(XBOB_IO_VERSION));
+  PyModule_AddStringConstant(m, "__version__", XBOB_IO_VERSION);
   PyModule_AddObject(m, "versions", build_version_dictionary());
 
   /* imports the NumPy C-API */
diff --git a/xbob/io/file.cpp b/xbob/io/file.cpp
index 867d5be..21b47e7 100644
--- a/xbob/io/file.cpp
+++ b/xbob/io/file.cpp
@@ -10,9 +10,9 @@
 #include <bob/io/CodecRegistry.h>
 #include <bob/io/utils.h>
 #include <numpy/arrayobject.h>
-#include <blitz.array/capi.h>
+#include <xbob.blitz/capi.h>
 #include <stdexcept>
-#include <bobskin.h>
+#include "bobskin.h"
 
 #define FILETYPE_NAME File
 PyDoc_STRVAR(s_file_str, BOOST_PP_STRINGIZE(XBOB_IO_MODULE_PREFIX) "." BOOST_PP_STRINGIZE(FILETYPE_NAME));
@@ -443,10 +443,10 @@ Parameters:\n\
 \n\
 array\n\
   [array] The array to be written into the file. It can be a\n\
-  numpy, a blitz array or any other object which can be\n\
+  numpy, a xbob.blitz.array or any other object which can be\n\
   converted to either of them, as long as the number of\n\
   dimensions and scalar type are supported by\n\
-  :py:class:`blitz.array`.\n\
+  :py:class:`xbob.blitz.array`.\n\
 \n\
 This method writes data to the file. It acts like the\n\
 given array is the only piece of data that will ever be written\n\
@@ -496,10 +496,10 @@ Parameters:\n\
 \n\
 array\n\
   [array] The array to be added into the file. It can be a\n\
-  numpy, a blitz array or any other object which can be\n\
+  numpy, a xbob.blitz.array or any other object which can be\n\
   converted to either of them, as long as the number of\n\
   dimensions and scalar type are supported by\n\
-  :py:class:`blitz.array`.\n\
+  :py:class:`xbob.blitz.array`.\n\
 \n\
 This method appends data to the file. If the file does not\n\
 exist, creates a new file, else, makes sure that the inserted\n\
diff --git a/xbob/io/hdf5.cpp b/xbob/io/hdf5.cpp
index 0deb128..82fe459 100644
--- a/xbob/io/hdf5.cpp
+++ b/xbob/io/hdf5.cpp
@@ -10,9 +10,9 @@
 
 #include <boost/make_shared.hpp>
 #include <numpy/arrayobject.h>
-#include <blitz.array/cppapi.h>
+#include <xbob.blitz/cppapi.h>
 #include <stdexcept>
-#include <bobskin.h>
+#include "bobskin.h"
 
 #define HDF5FILE_NAME HDF5File
 PyDoc_STRVAR(s_hdf5file_str, BOOST_PP_STRINGIZE(XBOB_IO_MODULE_PREFIX) "." BOOST_PP_STRINGIZE(HDF5FILE_NAME));
@@ -890,7 +890,7 @@ static bool PyBobIoHDF5File_IsPythonScalar(PyObject* obj) {
 
 /**
  * Returns the type of object `op' is - a scalar (return value = 0), a
- * blitz.array (return value = 1), a numpy.ndarray (return value = 2), an
+ * xbob.blitzarray (return value = 1), a numpy.ndarray (return value = 2), an
  * object which is convertible to a numpy.ndarray (return value = 3) or returns
  * -1 if the object cannot be converted. No error is set on the python stack.
  *
@@ -1118,7 +1118,7 @@ static PyObject* PyBobIoHDF5File_Replace(PyBobIoHDF5FileObject* self, PyObject*
     else { //write as array
 
       switch (is_array) {
-        case 1: //blitz.array
+        case 1: //xbob.blitz.array
           self->f->write_buffer(path, pos, type, ((PyBlitzArrayObject*)data)->data);
           break;
 
@@ -1252,7 +1252,7 @@ static int PyBobIoHDF5File_InnerAppend(PyBobIoHDF5FileObject* self, const char*
     else { //write as array
 
       switch (is_array) {
-        case 1: //blitz.array
+        case 1: //xbob.blitz.array
           if (!self->f->contains(path)) self->f->create(path, type, true, compression);
           self->f->extend_buffer(path, type, ((PyBlitzArrayObject*)data)->data);
           break;
@@ -1445,7 +1445,7 @@ static PyObject* PyBobIoHDF5File_Set(PyBobIoHDF5FileObject* self, PyObject* args
     else { //write as array
 
       switch (is_array) {
-        case 1: //blitz.array
+        case 1: //xbob.blitz.array
           if (!self->f->contains(path)) self->f->create(path, type, false, compression);
           self->f->write_buffer(path, 0, type, ((PyBlitzArrayObject*)data)->data);
           break;
@@ -1873,7 +1873,7 @@ static PyObject* PyBobIoHDF5File_WriteAttribute(PyBobIoHDF5FileObject* self,
     try {
       switch (is_array) {
 
-        case 1: //blitz.array
+        case 1: //xbob.blitz.array
           self->f->write_attribute(path, name, type, ((PyBlitzArrayObject*)o)->data);
           break;
 
diff --git a/xbob/io/main.cpp b/xbob/io/main.cpp
index 8a061d5..31064f6 100644
--- a/xbob/io/main.cpp
+++ b/xbob/io/main.cpp
@@ -11,7 +11,7 @@
 #ifdef NO_IMPORT_ARRAY
 #undef NO_IMPORT_ARRAY
 #endif
-#include <blitz.array/capi.h>
+#include <xbob.blitz/capi.h>
 
 static PyMethodDef module_methods[] = {
     {0}  /* Sentinel */
@@ -51,7 +51,7 @@ PyMODINIT_FUNC ENTRY_FUNCTION(XBOB_IO_MODULE_NAME) (void) {
 
   /* register some constants */
   PyModule_AddIntConstant(m, "__api_version__", XBOB_IO_API_VERSION);
-  PyModule_AddStringConstant(m, "__version__", BOOST_PP_STRINGIZE(XBOB_IO_VERSION));
+  PyModule_AddStringConstant(m, "__version__", XBOB_IO_VERSION);
 
   /* register the types to python */
   Py_INCREF(&PyBobIoFile_Type);
@@ -125,7 +125,7 @@ PyMODINIT_FUNC ENTRY_FUNCTION(XBOB_IO_MODULE_NAME) (void) {
   /* imports the NumPy C-API */
   import_array();
 
-  /* imports blitz.array C-API */
-  import_blitz_array();
+  /* imports xbob.blitz C-API */
+  import_xbob_blitz();
 
 }
diff --git a/xbob/io/videoreader.cpp b/xbob/io/videoreader.cpp
index 42c5bbd..0390aa5 100644
--- a/xbob/io/videoreader.cpp
+++ b/xbob/io/videoreader.cpp
@@ -11,9 +11,9 @@
 #if WITH_FFMPEG
 #include <boost/make_shared.hpp>
 #include <numpy/arrayobject.h>
-#include <blitz.array/capi.h>
+#include <xbob.blitz/capi.h>
 #include <stdexcept>
-#include <bobskin.h>
+#include "bobskin.h"
 
 #define VIDEOREADER_NAME VideoReader
 PyDoc_STRVAR(s_videoreader_str, BOOST_PP_STRINGIZE(XBOB_IO_MODULE_PREFIX) "." BOOST_PP_STRINGIZE(VIDEOREADER_NAME));
diff --git a/xbob/io/videowriter.cpp b/xbob/io/videowriter.cpp
index a7122ef..94ea02e 100644
--- a/xbob/io/videowriter.cpp
+++ b/xbob/io/videowriter.cpp
@@ -11,9 +11,9 @@
 #if WITH_FFMPEG
 #include <boost/make_shared.hpp>
 #include <numpy/arrayobject.h>
-#include <blitz.array/cppapi.h>
+#include <xbob.blitz/cppapi.h>
 #include <stdexcept>
-#include <bobskin.h>
+#include "bobskin.h"
 
 #define VIDEOWRITER_NAME VideoWriter
 PyDoc_STRVAR(s_videowriter_str, BOOST_PP_STRINGIZE(XBOB_IO_MODULE_PREFIX) "." BOOST_PP_STRINGIZE(VIDEOWRITER_NAME));
-- 
GitLab