From 736d20ea953c4031e1c9dc01875ff51a09fb1493 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 26 Jan 2024 12:29:46 +0100 Subject: [PATCH] python: Add version API calls New API calls in UHD Python API: - get_version_string() - get_abi_string() - get_component() --- host/lib/version_python.hpp | 19 +++++++++++++++++++ host/python/pyuhd.cpp | 4 ++++ host/python/uhd/__init__.py | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 host/lib/version_python.hpp diff --git a/host/lib/version_python.hpp b/host/lib/version_python.hpp new file mode 100644 index 000000000..af7f6175e --- /dev/null +++ b/host/lib/version_python.hpp @@ -0,0 +1,19 @@ +// +// Copyright 2024 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_UHD_VERSION_PYTHON_HPP +#define INCLUDED_UHD_VERSION_PYTHON_HPP + +#include + +void export_version(py::module& m) +{ + m.def("get_version_string", &uhd::get_version_string); + m.def("get_abi_string", &uhd::get_abi_string); + m.def("get_component", &uhd::get_component); +} + +#endif /* INCLUDED_UHD_VERSION_PYTHON_HPP */ diff --git a/host/python/pyuhd.cpp b/host/python/pyuhd.cpp index 7022a5287..930fb5193 100644 --- a/host/python/pyuhd.cpp +++ b/host/python/pyuhd.cpp @@ -46,6 +46,7 @@ namespace py = pybind11; #include "usrp/subdev_spec_python.hpp" #include "utils/paths_python.hpp" #include "utils/utils_python.hpp" +#include "version_python.hpp" // We need this hack because import_array() returns NULL // for newer Python versions. @@ -66,6 +67,9 @@ PYBIND11_MODULE(libpyuhd, m) // Register uhd::device::find export_device(m); + // Register version API + export_version(m); + // Register paths submodule auto paths_module = m.def_submodule("paths", "Path Utilities"); export_paths(paths_module); diff --git a/host/python/uhd/__init__.py b/host/python/uhd/__init__.py index b825cfa2e..fcfa6c158 100644 --- a/host/python/uhd/__init__.py +++ b/host/python/uhd/__init__.py @@ -16,6 +16,7 @@ from . import dsp from . import chdr from .libpyuhd.paths import * from .libpyuhd import find +from .libpyuhd import get_version_string, get_abi_string, get_component from .property_tree import PropertyTree - +__version__ = get_version_string()