aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/rfnoc-example/python/pyrfnoc-example.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/examples/rfnoc-example/python/pyrfnoc-example.cpp')
-rw-r--r--host/examples/rfnoc-example/python/pyrfnoc-example.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/host/examples/rfnoc-example/python/pyrfnoc-example.cpp b/host/examples/rfnoc-example/python/pyrfnoc-example.cpp
new file mode 100644
index 000000000..9dc69cb2c
--- /dev/null
+++ b/host/examples/rfnoc-example/python/pyrfnoc-example.cpp
@@ -0,0 +1,38 @@
+//
+// Copyright 2024 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+// NOTE: Most of these includes, as well as the numpy support, are not required
+// for rfnoc-example, but are commonly required
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#include <numpy/arrayobject.h>
+
+namespace py = pybind11;
+
+#include "gain_block_control_python.hpp"
+
+// We need this hack because import_array() returns NULL
+// for newer Python versions.
+// This function is also necessary because it ensures access to the C API
+// and removes a warning.
+void* init_numpy()
+{
+ import_array();
+ return NULL;
+}
+
+PYBIND11_MODULE(rfnoc_example_python, m)
+{
+ // Initialize the numpy C API
+ // (otherwise we will see segmentation faults)
+ init_numpy();
+
+ // uhd::rfnoc::python::export_noc_block_base(m);
+ export_gain_block_control(m);
+}