diff --git a/bob/io/base/cpp/CodecRegistry.cpp b/bob/io/base/cpp/CodecRegistry.cpp index 229d5802f0eaf6538b83d440ebdeeda4ab862488..821ecce8b94f7fe7ca0d073309322541ac60e7d1 100644 --- a/bob/io/base/cpp/CodecRegistry.cpp +++ b/bob/io/base/cpp/CodecRegistry.cpp @@ -7,15 +7,15 @@ * Copyright (C) Idiap Research Institute, Martigny, Switzerland */ +#include <bob.core/logging.h> + +#include <bob.io.base/CodecRegistry.h> + #include <vector> #include <boost/filesystem.hpp> #include <boost/format.hpp> -#include <bob.io.base/CodecRegistry.h> - -#include <bob/core/logging.h> - boost::shared_ptr<bob::io::base::CodecRegistry> bob::io::base::CodecRegistry::instance() { static boost::shared_ptr<bob::io::base::CodecRegistry> s_instance(new CodecRegistry()); return s_instance; @@ -58,7 +58,8 @@ void bob::io::base::CodecRegistry::registerExtension(const char* extension, else if (!s_ignore) { boost::format m("extension already registered: %s - ignoring second registration with description `%s'"); m % extension % description; - bob::core::error << m.str() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << m.str() << std::endl; throw std::runtime_error(m.str()); } diff --git a/bob/io/base/cpp/HDF5Attribute.cpp b/bob/io/base/cpp/HDF5Attribute.cpp index e701aced85c99ade1009ded61aaaf8e1e46b30cc..05d79bc3632d69981d3470606aca65bf2403172f 100644 --- a/bob/io/base/cpp/HDF5Attribute.cpp +++ b/bob/io/base/cpp/HDF5Attribute.cpp @@ -7,12 +7,12 @@ * Copyright (C) Idiap Research Institute, Martigny, Switzerland */ -#include <boost/format.hpp> - -#include <bob/core/logging.h> +#include <bob.core/logging.h> #include <bob.io.base/HDF5Attribute.h> +#include <boost/format.hpp> + static std::runtime_error status_error(const char* f, herr_t s) { boost::format m("call to HDF5 C-function %s() returned error %d. HDF5 error statck follows:\n%s"); m % f % s % bob::io::base::format_hdf5_error(); @@ -31,8 +31,9 @@ static void delete_h5dataspace (hid_t* p) { if (*p >= 0) { herr_t err = H5Sclose(*p); if (err < 0) { - bob::core::error << "H5Sclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Sclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; @@ -62,8 +63,9 @@ static void delete_h5type (hid_t* p) { if (*p >= 0) { herr_t err = H5Tclose(*p); if (err < 0) { - bob::core::error << "H5Tclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Tclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; @@ -99,8 +101,9 @@ static void delete_h5attribute (hid_t* p) { if (*p >= 0) { herr_t err = H5Aclose(*p); if (err < 0) { - bob::core::error << "H5Aclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Aclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; diff --git a/bob/io/base/cpp/HDF5Dataset.cpp b/bob/io/base/cpp/HDF5Dataset.cpp index 59b20939f77394d1ce287555bc397200d9fc5347..ac0167cfab9eff2abfa123c497727d49d16e9314 100644 --- a/bob/io/base/cpp/HDF5Dataset.cpp +++ b/bob/io/base/cpp/HDF5Dataset.cpp @@ -7,12 +7,12 @@ * Copyright (C) Idiap Research Institute, Martigny, Switzerland */ +#include <bob.core/logging.h> + #include <boost/format.hpp> #include <boost/make_shared.hpp> #include <boost/shared_array.hpp> -#include <bob/core/logging.h> - #include <bob.io.base/HDF5Utils.h> #include <bob.io.base/HDF5Group.h> #include <bob.io.base/HDF5Dataset.h> @@ -30,8 +30,9 @@ static void delete_h5dataset (hid_t* p) { if (*p >= 0) { herr_t err = H5Dclose(*p); if (err < 0) { - bob::core::error << "H5Dclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Dclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; @@ -61,8 +62,9 @@ static void delete_h5datatype (hid_t* p) { if (*p >= 0) { herr_t err = H5Tclose(*p); if (err < 0) { - bob::core::error << "H5Tclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Tclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; @@ -86,8 +88,9 @@ static void delete_h5plist (hid_t* p) { if (*p >= 0) { herr_t err = H5Pclose(*p); if (err < 0) { - bob::core::error << "H5Pclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Pclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; @@ -109,8 +112,9 @@ static void delete_h5dataspace (hid_t* p) { if (*p >= 0) { herr_t err = H5Sclose(*p); if (err < 0) { - bob::core::error << "H5Sclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Sclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; diff --git a/bob/io/base/cpp/HDF5Group.cpp b/bob/io/base/cpp/HDF5Group.cpp index aab916684071b0f51c260483f15c3a4dd3f0766d..43d2c1af4c77cedc7f9f7ac341ad78e1f18f44dc 100644 --- a/bob/io/base/cpp/HDF5Group.cpp +++ b/bob/io/base/cpp/HDF5Group.cpp @@ -7,14 +7,14 @@ * Copyright (C) Idiap Research Institute, Martigny, Switzerland */ +#include <bob.core/logging.h> + #include <boost/make_shared.hpp> #include <boost/shared_array.hpp> #include <boost/filesystem.hpp> #include <boost/format.hpp> #include <boost/algorithm/string.hpp> -#include <bob/core/logging.h> - #include <bob.io.base/HDF5Group.h> #include <bob.io.base/HDF5Utils.h> @@ -25,8 +25,9 @@ static void delete_h5g (hid_t* p) { if (*p >= 0) { herr_t err = H5Gclose(*p); if (err < 0) { - bob::core::error << "H5Gclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Gclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; @@ -311,8 +312,9 @@ static void delete_h5plist (hid_t* p) { if (*p >= 0) { herr_t err = H5Pclose(*p); if (err < 0) { - bob::core::error << "H5Pclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Pclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; diff --git a/bob/io/base/cpp/HDF5Types.cpp b/bob/io/base/cpp/HDF5Types.cpp index 16795bf8ba17e07326bcef4807cfe61188b15ab4..6e79ae14728abd082f7e0977489e4ac1a7a6c898 100644 --- a/bob/io/base/cpp/HDF5Types.cpp +++ b/bob/io/base/cpp/HDF5Types.cpp @@ -7,8 +7,10 @@ * Copyright (C) Idiap Research Institute, Martigny, Switzerland */ -#include <boost/format.hpp> +#include <bob.core/logging.h> + #include <sstream> +#include <boost/format.hpp> #include <boost/make_shared.hpp> /** @@ -24,8 +26,6 @@ #warning Disabling MT locks because Boost < 1.35! #endif -#include <bob/core/logging.h> - #include <bob.io.base/HDF5Types.h> const char* bob::io::base::stringize (hdf5type t) { @@ -213,8 +213,9 @@ static void delete_h5datatype (hid_t* p) { if (*p >= 0) { herr_t err = H5Tclose(*p); if (err < 0) { - bob::core::error << "H5Tclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Tclose() exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; diff --git a/bob/io/base/cpp/HDF5Utils.cpp b/bob/io/base/cpp/HDF5Utils.cpp index b735be4a22414eee60c8d3a30c83b2246648b881..3cbff40478240d40c581019735c1121403384bd8 100644 --- a/bob/io/base/cpp/HDF5Utils.cpp +++ b/bob/io/base/cpp/HDF5Utils.cpp @@ -7,11 +7,11 @@ * Copyright (C) Idiap Research Institute, Martigny, Switzerland */ +#include <bob.core/logging.h> + #include <boost/format.hpp> #include <boost/make_shared.hpp> -#include <bob/core/logging.h> - #include <bob.io.base/HDF5Utils.h> /** @@ -21,8 +21,9 @@ static void delete_h5file (hid_t* p) { if (*p >= 0) { herr_t err = H5Fclose(*p); if (err < 0) { - bob::core::error << "H5Fclose(hid=" << *p << ") exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Fclose(hid=" << *p << ") exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; } } delete p; @@ -35,8 +36,9 @@ static void delete_h5p (hid_t* p) { if (*p >= 0) { herr_t err = H5Pclose(*p); if (err < 0) { - bob::core::error << "H5Pclose(hid=" << *p << ") exited with an error (" << err << "). The stack trace follows:" << std::endl; - bob::core::error << bob::io::base::format_hdf5_error() << std::endl; + auto& error_stream = PyBobCoreLogging_Error(); + error_stream << "H5Pclose(hid=" << *p << ") exited with an error (" << err << "). The stack trace follows:" << std::endl; + error_stream << bob::io::base::format_hdf5_error() << std::endl; return; } } diff --git a/bob/io/base/main.cpp b/bob/io/base/main.cpp index f7dfb87c59465b2d49985e641f6a765e16d22e61..27f18a04cc2a277afcb911639643edd53b68ae2b 100644 --- a/bob/io/base/main.cpp +++ b/bob/io/base/main.cpp @@ -13,6 +13,7 @@ #endif #include <bob.blitz/capi.h> #include <bob.blitz/cleanup.h> +#include <bob.core/logging.h> /** * Creates an str object, from a C or C++ string. Returns a **new @@ -177,6 +178,13 @@ static PyObject* create_module (void) { if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) return 0; + /* imports dependencies */ + if (import_bob_core_logging() < 0) { + PyErr_Print(); + PyErr_Format(PyExc_ImportError, "cannot import `%s'", BOB_EXT_MODULE_NAME); + return 0; + } + /* imports dependencies */ if (import_bob_blitz() < 0) { PyErr_Print(); diff --git a/setup.py b/setup.py index d3eac6e1516469f234f98bcff7b8fcf8692bfa41..58a37d7161fa5a20c3a9cb48b861fd7e375667af 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,6 @@ package_dir = os.path.dirname(os.path.realpath(__file__)) package_dir = os.path.join(package_dir, 'bob', 'io', 'base', 'include') include_dirs = [package_dir, bob.core.get_include()] -packages = ['bob-core >= 1.2.2'] version = '2.0.0a0' def libhdf5_version(header): @@ -148,6 +147,7 @@ setup( install_requires=[ 'setuptools', 'bob.blitz', + 'bob.core', ], namespace_packages=[ @@ -160,11 +160,11 @@ setup( [ "bob/io/base/version.cpp", ], - packages = packages, include_dirs = include_dirs, define_macros = define_macros, extra_compile_args = extra_compile_args, version = version, + packages = ['boost'], ), Extension("bob.io.base._library", [ @@ -194,13 +194,14 @@ setup( "bob/io/base/hdf5.cpp", "bob/io/base/main.cpp", ], - packages = packages, include_dirs = include_dirs, library_dirs = library_dirs, libraries = libraries, define_macros = define_macros, extra_compile_args = extra_compile_args, version = version, + packages = ['boost'], + boost_modules = ['iostreams', 'filesystem'], ), ],