python: Add version API calls

New API calls in UHD Python API:
- get_version_string()
- get_abi_string()
- get_component()
This commit is contained in:
Martin Braun 2024-01-26 12:29:46 +01:00 committed by Aki Tomita
parent f3815f3384
commit 736d20ea95
3 changed files with 25 additions and 1 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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()