]> git.ipfire.org Git - pakfire.git/commitdiff
python: Add __version__
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 17:32:33 +0000 (17:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 17:32:33 +0000 (17:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
src/python/pakfiremodule.c
tests/python/ctx.py

index 063c7a9e12b699cf424997f8d32d5938b552cb6f..2f4c20082b1f769ee799b8360c35eeea1d3d0016 100644 (file)
@@ -10,7 +10,6 @@
 /pakfire-builder
 /pakfire-client
 /pakfire-daemon
-/src/pakfire/__version__.py
 /src/systemd/*.service
 /tests/.root
 /tests/libpakfire/arch
index 92142b23df426f1fcf7fb0a58f13a9375bc4e44c..4a4712ea6b34b9bc6d79eceba042606f0345f7a4 100644 (file)
@@ -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);
index b7e1126a85e6467bc81e1b2f2be4b21a2245df26..b0584f4779df4d6bf5147d732c5dc5219dab2ed6 100755 (executable)
@@ -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