$darkmode
LuPNT 0.1
LuPNT
|
Python bindings of the lupnt library
Suppose you want to add the python bindings to "XXX.cpp" and "XXX.h"
void init_xxx(py::module &m)
in MainBindings.cpp
init_xxx(m)
in the PYBIND11_MODULE
in MainBindings.cpp
PyXXX.cpp
in the bindings/
folderIn PythonXXX.cpp
, define your bindings as follows. Refer to the official document on how to write the bindings. ``` #include <pybind11/pybind11.h> #include <lupnt/path/to/XXX.h>
namespace py = pybind11; using namespace LPT;
void init_state(py::module &m){ /* define your bindings here */ } ```
.vscode/settings.json
``` { // cmake settings "cmake.configureArgs": [ "-DPYTHON_INCLUDE_DIRS=path1string", "-DPYTHON_LIBRARIES=path2string" "-DBUILD_EXAMPLES=ON" ] } ``
Install the updated python library to local from the root directory of this project. Don't forget to create a new local environment and activate it (
python3 -m venv venv, and
. venv/bin/activateor
source .venv/bin/activate) if you don't want to install it globally.
`` pip install . ``
Create a test under
test_python/
Test your bindings with
python3 -m pytest test_python
`