Commit 41a8cfe2 authored by Manuel Günther's avatar Manuel Günther
Browse files

Getting module imports correct

parent c4455b5a
......@@ -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 */
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment