diff options
author | Martin Braun <martin.braun@ettus.com> | 2024-01-26 12:29:46 +0100 |
---|---|---|
committer | Aki Tomita <121511582+atomita-ni@users.noreply.github.com> | 2024-01-30 13:37:07 -0600 |
commit | 736d20ea953c4031e1c9dc01875ff51a09fb1493 (patch) | |
tree | 60598f920d3510c7f0f702276ad086c59b074e50 /host | |
parent | python: Fix setting start_time having no effect (diff) | |
download | uhd-736d20ea953c4031e1c9dc01875ff51a09fb1493.tar.xz uhd-736d20ea953c4031e1c9dc01875ff51a09fb1493.zip |
python: Add version API calls
New API calls in UHD Python API:
- get_version_string()
- get_abi_string()
- get_component()
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/version_python.hpp | 19 | ||||
-rw-r--r-- | host/python/pyuhd.cpp | 4 | ||||
-rw-r--r-- | host/python/uhd/__init__.py | 3 |
3 files changed, 25 insertions, 1 deletions
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 <uhd/version.hpp> + +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() |