diff --git a/bob/learn/em/__init__.py b/bob/learn/em/__init__.py index bf6f3fa3f379f8edc841485c41ee0a7a5ec96478..62f331b0b27c688714bd5d689b31bc1261e6cfd2 100644 --- a/bob/learn/em/__init__.py +++ b/bob/learn/em/__init__.py @@ -10,8 +10,10 @@ bob.extension.load_bob_library('bob.learn.em', __file__) from ._library import * from . import version from .version import module as __version__ +from .version import api as __api_version__ from .train import * + def ztnorm_same_value(vect_a, vect_b): """Computes the matrix of boolean D for the ZT-norm, which indicates where the client ids of the T-Norm models and Z-Norm samples match. @@ -30,21 +32,8 @@ def ztnorm_same_value(vect_a, vect_b): def get_config(): """Returns a string containing the configuration information. """ + return bob.extension.get_config(__name__, version.externals, version.api) - import pkg_resources - from .version import externals - - packages = pkg_resources.require(__name__) - this = packages[0] - deps = packages[1:] - - retval = "%s: %s (%s)\n" % (this.key, this.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/bob/learn/em/main.cpp b/bob/learn/em/main.cpp index 6444c996cf1e8c4fd68f8168f2e226f705171cf7..dca7d7d69fae2f43087e2c52568fbbbbdb8e01d3 100644 --- a/bob/learn/em/main.cpp +++ b/bob/learn/em/main.cpp @@ -66,13 +66,12 @@ static PyObject* create_module (void) { if (!module) return 0; auto module_ = make_safe(module); ///< protects against early returns - if (PyModule_AddStringConstant(module, "__version__", BOB_EXT_MODULE_VERSION) < 0) return 0; if (!init_BobLearnEMGaussian(module)) return 0; if (!init_BobLearnEMGMMStats(module)) return 0; if (!init_BobLearnEMGMMMachine(module)) return 0; if (!init_BobLearnEMKMeansMachine(module)) return 0; if (!init_BobLearnEMKMeansTrainer(module)) return 0; - if (!init_BobLearnEMMLGMMTrainer(module)) return 0; + if (!init_BobLearnEMMLGMMTrainer(module)) return 0; if (!init_BobLearnEMMAPGMMTrainer(module)) return 0; if (!init_BobLearnEMJFABase(module)) return 0; @@ -85,12 +84,12 @@ static PyObject* create_module (void) { if (!init_BobLearnEMIVectorMachine(module)) return 0; if (!init_BobLearnEMIVectorTrainer(module)) return 0; - + if (!init_BobLearnEMPLDABase(module)) return 0; if (!init_BobLearnEMPLDAMachine(module)) return 0; - if (!init_BobLearnEMPLDATrainer(module)) return 0; + if (!init_BobLearnEMPLDATrainer(module)) return 0; - if (!init_BobLearnEMEMPCATrainer(module)) return 0; + if (!init_BobLearnEMEMPCATrainer(module)) return 0; static void* PyBobLearnEM_API[PyBobLearnEM_API_pointers]; @@ -128,9 +127,7 @@ static PyObject* create_module (void) { if (import_bob_io_base() < 0) return 0; if (import_bob_learn_linear() < 0) return 0; - Py_INCREF(module); - return module; - + return Py_BuildValue("O", module); } PyMODINIT_FUNC BOB_EXT_ENTRY_NAME (void) { diff --git a/bob/learn/em/version.cpp b/bob/learn/em/version.cpp index 741a8c346d15615c20865f1ba6693076fd4402cc..dbf0b5fa72aa4a46698461cf3e785724a0c4c59f 100644 --- a/bob/learn/em/version.cpp +++ b/bob/learn/em/version.cpp @@ -17,6 +17,7 @@ #include <bob.math/config.h> #include <bob.learn.activation/config.h> #include <bob.learn.linear/config.h> +#include <bob.learn.em/config.h> // TODO: add other dependencies #include <string> @@ -196,8 +197,8 @@ static PyObject* create_module (void) { auto m_ = make_safe(m); ///< protects against early returns /* register version numbers and constants */ - if (PyModule_AddStringConstant(m, "module", BOB_EXT_MODULE_VERSION) < 0) - return 0; + if (PyModule_AddIntConstant(m, "api", BOB_LEARN_EM_API_VERSION) < 0) return 0; + if (PyModule_AddStringConstant(m, "module", BOB_EXT_MODULE_VERSION) < 0) return 0; PyObject* externals = build_version_dictionary(); if (!externals) return 0; @@ -210,9 +211,7 @@ static PyObject* create_module (void) { return 0; } - Py_INCREF(m); - return m; - + return Py_BuildValue("O", m); } PyMODINIT_FUNC BOB_EXT_ENTRY_NAME (void) {