From 3f168e1fce0c8b54198de7017e9594f0ec07ddc7 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Sat, 22 Mar 2014 20:34:57 +0100 Subject: [PATCH] Add function to print comprehensive dependence list --- xbob/io/__init__.py | 20 ++++++++++++++++ xbob/io/version.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/xbob/io/__init__.py b/xbob/io/__init__.py index 24a3ecd..62541ea 100644 --- a/xbob/io/__init__.py +++ b/xbob/io/__init__.py @@ -180,5 +180,25 @@ def get_include(): return __import__('pkg_resources').resource_filename(__name__, 'include') +def get_config(): + """Returns a string containing the configuration information. + """ + + import pkg_resources + from .version import externals + + packages = pkg_resources.require(__name__) + this = packages[0] + deps = packages[1:] + + retval = "%s: %s [api=0x%04x] (%s)\n" % (this.key, this.version, + __api_version__, this.location) + retval += " - c/c++ dependencies:\n" + for k in sorted(externals): retval += " - %s: %s\n" % (k, externals[k]) + retval += " - python dependencies:\n" + for d in deps: retval += " - %s: %s (%s)\n" % (d.key, d.version, d.location) + + return retval.strip() + # gets sphinx autodoc done right - don't remove it __all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/xbob/io/version.cpp b/xbob/io/version.cpp index b091087..9a6f6ec 100644 --- a/xbob/io/version.cpp +++ b/xbob/io/version.cpp @@ -16,6 +16,7 @@ #include <string> #include <cstdlib> #include <boost/preprocessor/stringize.hpp> +#include <boost/version.hpp> #include <boost/format.hpp> #include <bob/config.h> @@ -283,6 +284,55 @@ static PyObject* bob_version() { return Py_BuildValue("sis", BOB_VERSION, BOB_API_VERSION, BOB_PLATFORM); } +/** + * Describes the version of Boost libraries installed + */ +static PyObject* boost_version() { + boost::format f("%d.%d.%d"); + f % (BOOST_VERSION / 100000); + f % (BOOST_VERSION / 100 % 1000); + f % (BOOST_VERSION % 100); + return Py_BuildValue("s", f.str().c_str()); +} + +/** + * Describes the compiler version + */ +static PyObject* compiler_version() { +# if defined(__GNUC__) && !defined(__llvm__) + boost::format f("%s.%s.%s"); + f % BOOST_PP_STRINGIZE(__GNUC__); + f % BOOST_PP_STRINGIZE(__GNUC_MINOR__); + f % BOOST_PP_STRINGIZE(__GNUC_PATCHLEVEL__); + return Py_BuildValue("{ssss}", "name", "gcc", "version", f.str().c_str()); +# elif defined(__llvm__) && !defined(__clang__) + return Py_BuildValue("{ssss}", "name", "llvm-gcc", "version", __VERSION__); +# elif defined(__clang__) + return Py_BuildValue("{ssss}", "name", "clang", "version", __clang_version__); +# else + return Py_BuildValue("{ssss}", "name", "unsupported", "version", "unknown"); +# endif +} + +/** + * Python version with which we compiled the extensions + */ +static PyObject* python_version() { + boost::format f("%s.%s.%s"); + f % BOOST_PP_STRINGIZE(PY_MAJOR_VERSION); + f % BOOST_PP_STRINGIZE(PY_MINOR_VERSION); + f % BOOST_PP_STRINGIZE(PY_MICRO_VERSION); + return Py_BuildValue("s", f.str().c_str()); +} + +/** + * Numpy version + */ +static PyObject* numpy_version() { + return Py_BuildValue("{ssss}", "abi", BOOST_PP_STRINGIZE(NPY_VERSION), + "api", BOOST_PP_STRINGIZE(NPY_API_VERSION)); +} + static PyObject* build_version_dictionary() { PyObject* retval = PyDict_New(); @@ -307,6 +357,14 @@ static PyObject* build_version_dictionary() { if (!dict_steal(retval, "MatIO", matio_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; + + if (!dict_steal(retval, "NumPy", numpy_version())) return 0; + Py_INCREF(retval); return retval; } -- GitLab