Skip to content
Snippets Groups Projects
Commit 41a8cfe2 authored by Manuel Günther's avatar Manuel Günther
Browse files

Getting module imports correct

parent c4455b5a
No related branches found
No related tags found
No related merge requests found
...@@ -301,28 +301,4 @@ typedef struct { ...@@ -301,28 +301,4 @@ typedef struct {
#endif /* BOB_IO_BASE_MODULE */ #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 */ #endif /* BOB_IO_BASE_H */
...@@ -21,6 +21,18 @@ ...@@ -21,6 +21,18 @@
#include <Python.h> #include <Python.h>
#include <boost/preprocessor/stringize.hpp> #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 * bob.io.base c/c++ api version
......
...@@ -162,11 +162,7 @@ static PyObject* create_module (void) { ...@@ -162,11 +162,7 @@ static PyObject* create_module (void) {
if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) return 0; if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) return 0;
/* imports dependencies */ /* imports dependencies */
if (import_bob_blitz() < 0) { if (import_bob_blitz() < 0) return 0;
PyErr_Print();
PyErr_Format(PyExc_ImportError, "cannot import `%s'", BOB_EXT_MODULE_NAME);
return 0;
}
return Py_BuildValue("O", m); return Py_BuildValue("O", m);
......
...@@ -6,19 +6,11 @@ ...@@ -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_IMPORT_VERSION
#define BOB_IO_BASE_MODULE #include <bob.blitz/config.h>
#ifdef NO_IMPORT_ARRAY #include <bob.blitz/cleanup.h>
#undef NO_IMPORT_ARRAY #include <bob.core/config.h>
#endif #include <bob.io.base/config.h>
#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>
static PyObject* build_version_dictionary() { static PyObject* build_version_dictionary() {
...@@ -31,7 +23,7 @@ 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, "Compiler", compiler_version())) return 0;
if (!dict_steal(retval, "Python", python_version())) return 0; if (!dict_steal(retval, "Python", python_version())) return 0;
if (!dict_steal(retval, "NumPy", numpy_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.blitz", bob_blitz_version())) return 0;
if (!dict_steal(retval, "bob.core", bob_core_version())) return 0; if (!dict_steal(retval, "bob.core", bob_core_version())) return 0;
...@@ -74,9 +66,8 @@ static PyObject* create_module (void) { ...@@ -74,9 +66,8 @@ static PyObject* create_module (void) {
return 0; return 0;
if (PyModule_AddObject(m, "externals", build_version_dictionary()) < 0) return 0; if (PyModule_AddObject(m, "externals", build_version_dictionary()) < 0) return 0;
/* imports dependencies */ // call bob_io_base_version once to avoid compiler warning
if (import_bob_blitz() < 0) return 0; auto _ = make_safe(bob_io_base_version());
if (import_bob_core_logging() < 0) return 0;
return Py_BuildValue("O", m); return Py_BuildValue("O", m);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment