From ebd3d8d0449d63a2c99acd902ebab729035e8e4d Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.dos.anjos@gmail.com>
Date: Tue, 3 Dec 2013 14:42:00 +0100
Subject: [PATCH] Register the C-API on the module

---
 xbob/io/main.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/xbob/io/main.cpp b/xbob/io/main.cpp
index 215c206..db8f872 100644
--- a/xbob/io/main.cpp
+++ b/xbob/io/main.cpp
@@ -119,6 +119,21 @@ PyMODINIT_FUNC XBOB_EXT_ENTRY_NAME (void) {
 
   PyXbobIo_API[PyBobIoHDF5File_Converter_NUM] = (void *)&PyBobIoHDF5File_Converter;
 
+#if PY_VERSION_HEX >= 0x02070000
+
+  /* defines the PyCapsule */
+
+  PyObject* c_api_object = PyCapsule_New((void *)PyXbobIo_API,
+      XBOB_EXT_MODULE_PREFIX "." XBOB_EXT_MODULE_NAME "._C_API", 0);
+
+#else
+
+  PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyXbobIo_API, 0);
+
+#endif
+
+  if (c_api_object) PyModule_AddObject(m, "_C_API", c_api_object);
+
   /* imports the NumPy C-API */
   import_array();
 
-- 
GitLab