Python package using Pybind11
설치
sudo apt install -y libffi-dev python3 python3-pip python3-dev \
&& python3 -m pip install -U pip setuptools wheel twine keyrings.alt pybind11 build
Package directory structure
workspace
├── LICENSE
├── MANIFEST.in
├── README.md
├── CHANGELOG
├── setup.cfg
├── setup.py
├── c_src
│ └── ...
└── py_src
└── package
├── test
| ├── __init__.py
| └── ...
├── subPackage
│ ├── __init__.py
│ └── module1.py
├── __init__.py
└── __main__.py
C/C++
function
#include <pybind11/pybind11.h>
namespace py = pybind11;
int add(int i, int j) { return i + j; }
PYBIND11_MODULE(_<package>, m) {
// m.def( "add", &add );
m.def("add",
&add,
"A function which adds two numbers",
py::arg("i") = 1,
py::arg("j") = 2);
}