From e3b7f1fa5f80281b12b58463a58f3ff75e1bb328 Mon Sep 17 00:00:00 2001 From: Manuel Guenther <manuel.guenther@idiap.ch> Date: Thu, 21 May 2015 15:20:42 +0200 Subject: [PATCH] Getting module imports correct --- bob/math/main.cpp | 8 +++----- bob/math/version.cpp | 12 +++--------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/bob/math/main.cpp b/bob/math/main.cpp index 7e271f4..4f70e35 100644 --- a/bob/math/main.cpp +++ b/bob/math/main.cpp @@ -10,6 +10,7 @@ #endif #include <bob.blitz/capi.h> #include <bob.blitz/cleanup.h> +#include <bob.core/api.h> #include <bob.extension/documentation.h> @@ -525,11 +526,8 @@ static PyObject* create_module (void) { (PyObject *)&PyBobMathLpInteriorPointLongstep_Type) < 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; + if (import_bob_core_logging() < 0) return 0; return Py_BuildValue("O", m); } diff --git a/bob/math/version.cpp b/bob/math/version.cpp index ac0d00e..537bae6 100644 --- a/bob/math/version.cpp +++ b/bob/math/version.cpp @@ -8,11 +8,8 @@ #include <bob.math/config.h> #define BOB_IMPORT_VERSION -#ifdef NO_IMPORT_ARRAY -#undef NO_IMPORT_ARRAY -#endif -#include <bob.blitz/capi.h> -#include <bob.core/api.h> +#include <bob.blitz/config.h> +#include <bob.core/config.h> static PyObject* build_version_dictionary() { @@ -20,7 +17,7 @@ static PyObject* build_version_dictionary() { if (!retval) return 0; auto retval_ = make_safe(retval); - if (!dict_set(retval, "Blitz++", BZ_VERSION)) return 0; + if (!dict_steal(retval, "Blitz++", blitz_version())) return 0; if (!dict_steal(retval, "Boost", boost_version())) return 0; if (!dict_steal(retval, "Compiler", compiler_version())) return 0; if (!dict_steal(retval, "Python", python_version())) return 0; @@ -68,9 +65,6 @@ static PyObject* create_module (void) { if (!externals) return 0; if (PyModule_AddObject(m, "externals", externals) < 0) return 0; - if (import_bob_blitz() < 0) return 0; - if (import_bob_core_logging() < 0) return 0; - return Py_BuildValue("O", m); } -- GitLab