From: Michael Tremer Date: Sat, 12 Oct 2024 17:32:33 +0000 (+0000) Subject: python: Add __version__ X-Git-Tag: 0.9.30~1060 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=605de077cc4e3f150cbcae2eb761cf36e426fc6e;p=pakfire.git python: Add __version__ Signed-off-by: Michael Tremer --- diff --git a/.gitignore b/.gitignore index 063c7a9e1..2f4c20082 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ /pakfire-builder /pakfire-client /pakfire-daemon -/src/pakfire/__version__.py /src/systemd/*.service /tests/.root /tests/libpakfire/arch diff --git a/src/python/pakfiremodule.c b/src/python/pakfiremodule.c index 92142b23d..4a4712ea6 100644 --- a/src/python/pakfiremodule.c +++ b/src/python/pakfiremodule.c @@ -119,11 +119,18 @@ static struct PyModuleDef moduledef = { }; PyMODINIT_FUNC PyInit_pakfire(void) { + int r; + // Create the module PyObject* module = PyModule_Create(&moduledef); if (!module) return NULL; + // Add the version + r = PyModule_AddStringConstant(module, "__version__", PACKAGE_VERSION); + if (r < 0) + goto ERROR; + PyExc_BadSignatureError = PyErr_NewException("pakfire.BadSignatureError", NULL, NULL); Py_INCREF(PyExc_BadSignatureError); PyModule_AddObject(module, "BadSignatureError", PyExc_BadSignatureError); diff --git a/tests/python/ctx.py b/tests/python/ctx.py index b7e1126a8..b0584f477 100755 --- a/tests/python/ctx.py +++ b/tests/python/ctx.py @@ -28,6 +28,9 @@ class CtxTests(tests.TestCase): """ This tests the pakfire context """ + def test_version(self): + self.assertIsInstance(pakfire.__version__, str) + def test_create(self): """ Create a context without any further ado