From 6cd722d9507200a90b7c99dcb6749187aa757f87 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Oct 2010 13:17:25 +0200 Subject: pytdb: Add __version__ attribute. --- lib/tdb/pytdb.c | 2 ++ lib/tdb/python/tests/simple.py | 6 ++++++ lib/tdb/wscript | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/tdb') diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c index 15fec21e53..b857438e16 100644 --- a/lib/tdb/pytdb.c +++ b/lib/tdb/pytdb.c @@ -592,6 +592,8 @@ void inittdb(void) PyModule_AddObject(m, "__docformat__", PyString_FromString("restructuredText")); + PyModule_AddObject(m, "__version__", PyString_FromString(PACKAGE_VERSION)); + Py_INCREF(&PyTdb); PyModule_AddObject(m, "Tdb", (PyObject *)&PyTdb); diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py index 6386a2871f..f5484a0523 100644 --- a/lib/tdb/python/tests/simple.py +++ b/lib/tdb/python/tests/simple.py @@ -165,6 +165,12 @@ class SimpleTdbTests(TestCase): self.tdb.remove_flags(tdb.NOMMAP) +class VersionTests(TestCase): + + def test_present(self): + self.assertTrue(isinstance(tdb.__version__, str)) + + if __name__ == '__main__': import unittest unittest.TestProgram() diff --git a/lib/tdb/wscript b/lib/tdb/wscript index 94f85cd708..d9c0ceb41b 100644 --- a/lib/tdb/wscript +++ b/lib/tdb/wscript @@ -98,7 +98,8 @@ def build(bld): 'pytdb.c', deps='tdb', enabled=not bld.env.disable_python, - realname='tdb.so') + realname='tdb.so', + cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION) if bld.env.standalone_tdb: bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig' -- cgit