diff --git a/python/notcurses/__init__.py b/python/notcurses/__init__.py index 87093f637..d4371e6c6 100644 --- a/python/notcurses/__init__.py +++ b/python/notcurses/__init__.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .misc import notcurses_version +from .misc import notcurses_version, notcurses_version_components -__all__ = [ - 'notcurses_version', -] +__all__ = ( + 'notcurses_version', 'notcurses_version_components' +) diff --git a/python/notcurses/misc.c b/python/notcurses/misc.c index 59f5b7053..68e87aad7 100644 --- a/python/notcurses/misc.c +++ b/python/notcurses/misc.c @@ -24,8 +24,19 @@ python_notcurses_version(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) return PyUnicode_FromString(verstion_str); } +static PyObject * +python_notcurses_version_components(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) +{ + int major, minor, patch, tweak = {0}; + + notcurses_version_components(&major, &minor, &patch, &tweak); + + return Py_BuildValue("iiii", major, minor, patch, tweak); +} + static PyMethodDef NotcursesMiscMethods[] = { {"notcurses_version", (PyCFunction)python_notcurses_version, METH_NOARGS, "Get a human-readable string describing the running Notcurses version."}, + {"notcurses_version_components", (PyCFunction)python_notcurses_version_components, METH_NOARGS, "Get a tuple of major, minor, patch, tweak integer of the running Notcurses version."}, {NULL, NULL, 0, NULL}, };