diff --git a/bob/io/base/include/bob.io.base/api.h b/bob/io/base/include/bob.io.base/api.h index b6858aa8d19209605c2dcfa31dffaba64726bba3..fc7fb6f341a7658b9fbda8b353bc39273e999e1f 100644 --- a/bob/io/base/include/bob.io.base/api.h +++ b/bob/io/base/include/bob.io.base/api.h @@ -301,28 +301,4 @@ typedef struct { #endif /* BOB_IO_BASE_MODULE */ - -#ifdef BOB_IMPORT_VERSION - - /*************************************** - * Here we define some functions that should be used to build version dictionaries in the version.cpp file - * There will be a compiler warning, when these functions are not used, so use them! - ***************************************/ - - #include <boost/preprocessor/stringize.hpp> - #include <hdf5.h> - - /** - * The version of HDF5 - */ - static PyObject* hdf5_version() { - boost::format f("%s.%s.%s"); - f % BOOST_PP_STRINGIZE(H5_VERS_MAJOR); - f % BOOST_PP_STRINGIZE(H5_VERS_MINOR); - f % BOOST_PP_STRINGIZE(H5_VERS_RELEASE); - return Py_BuildValue("s", f.str().c_str()); - } - -#endif // BOB_IMPORT_VERSION - #endif /* BOB_IO_BASE_H */ diff --git a/bob/io/base/include/bob.io.base/config.h b/bob/io/base/include/bob.io.base/config.h index 24cd8fd0617a50091a858cd54ced43d5cf500666..a3f9627ab34c6eeb2de3568147f2d7ac5b799734 100644 --- a/bob/io/base/include/bob.io.base/config.h +++ b/bob/io/base/include/bob.io.base/config.h @@ -21,6 +21,18 @@ #include <Python.h> #include <boost/preprocessor/stringize.hpp> + #include <hdf5.h> + + /** + * The version of HDF5 + */ + static PyObject* hdf5_version() { + boost::format f("%s.%s.%s"); + f % BOOST_PP_STRINGIZE(H5_VERS_MAJOR); + f % BOOST_PP_STRINGIZE(H5_VERS_MINOR); + f % BOOST_PP_STRINGIZE(H5_VERS_RELEASE); + return Py_BuildValue("s", f.str().c_str()); + } /** * bob.io.base c/c++ api version diff --git a/bob/io/base/main.cpp b/bob/io/base/main.cpp index 4499bf0d6a853024fc914c882b63e7ab89128390..c6ae75406bfd8b8788b8113b7579d139c2b700e6 100644 --- a/bob/io/base/main.cpp +++ b/bob/io/base/main.cpp @@ -162,11 +162,7 @@ static PyObject* create_module (void) { if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) return 0; /* imports dependencies */ - if (import_bob_blitz() < 0) { - PyErr_Print(); - PyErr_Format(PyExc_ImportError, "cannot import `%s'", BOB_EXT_MODULE_NAME); - return 0; - } + if (import_bob_blitz() < 0) return 0; return Py_BuildValue("O", m); diff --git a/bob/io/base/version.cpp b/bob/io/base/version.cpp index a25227019ea53019886c95af54e465358ca6724b..5ad70c6c29d47865610bf98771679ed59b996d93 100644 --- a/bob/io/base/version.cpp +++ b/bob/io/base/version.cpp @@ -6,19 +6,11 @@ */ -// include config.h without defining the bob_io_base_version function -#include <bob.io.base/config.h> - #define BOB_IMPORT_VERSION -#define BOB_IO_BASE_MODULE -#ifdef NO_IMPORT_ARRAY -#undef NO_IMPORT_ARRAY -#endif - -#include <bob.blitz/capi.h> -#include <bob.core/api.h> -// This will include config.h again, but will not do anything since its header guard is already defined. -#include <bob.io.base/api.h> +#include <bob.blitz/config.h> +#include <bob.blitz/cleanup.h> +#include <bob.core/config.h> +#include <bob.io.base/config.h> static PyObject* build_version_dictionary() { @@ -31,7 +23,7 @@ static PyObject* build_version_dictionary() { if (!dict_steal(retval, "Compiler", compiler_version())) return 0; if (!dict_steal(retval, "Python", python_version())) return 0; if (!dict_steal(retval, "NumPy", numpy_version())) return 0; - if (!dict_set(retval, "Blitz++", BZ_VERSION)) return 0; + if (!dict_steal(retval, "Blitz++", blitz_version())) return 0; if (!dict_steal(retval, "bob.blitz", bob_blitz_version())) return 0; if (!dict_steal(retval, "bob.core", bob_core_version())) return 0; @@ -74,9 +66,8 @@ static PyObject* create_module (void) { return 0; if (PyModule_AddObject(m, "externals", build_version_dictionary()) < 0) return 0; - /* imports dependencies */ - if (import_bob_blitz() < 0) return 0; - if (import_bob_core_logging() < 0) return 0; + // call bob_io_base_version once to avoid compiler warning + auto _ = make_safe(bob_io_base_version()); return Py_BuildValue("O", m);