|
|
|
@ -4,14 +4,10 @@ int add(int i, int j) {
@@ -4,14 +4,10 @@ int add(int i, int j) {
|
|
|
|
|
return i + j; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int subtract(int i, int j) { |
|
|
|
|
return i - j; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
namespace py = pybind11; |
|
|
|
|
|
|
|
|
|
PYBIND11_PLUGIN(python_example) { |
|
|
|
|
py::module m("python_example", R"pbdoc( |
|
|
|
|
PYBIND11_MODULE(python_example, m) { |
|
|
|
|
m.doc() = R"pbdoc( |
|
|
|
|
Pybind11 example plugin |
|
|
|
|
----------------------- |
|
|
|
|
|
|
|
|
@ -22,7 +18,7 @@ PYBIND11_PLUGIN(python_example) {
@@ -22,7 +18,7 @@ PYBIND11_PLUGIN(python_example) {
|
|
|
|
|
|
|
|
|
|
add |
|
|
|
|
subtract |
|
|
|
|
)pbdoc"); |
|
|
|
|
)pbdoc"; |
|
|
|
|
|
|
|
|
|
m.def("add", &add, R"pbdoc( |
|
|
|
|
Add two numbers |
|
|
|
@ -30,17 +26,15 @@ PYBIND11_PLUGIN(python_example) {
@@ -30,17 +26,15 @@ PYBIND11_PLUGIN(python_example) {
|
|
|
|
|
Some other explanation about the add function. |
|
|
|
|
)pbdoc"); |
|
|
|
|
|
|
|
|
|
m.def("subtract", &subtract, R"pbdoc( |
|
|
|
|
m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc( |
|
|
|
|
Subtract two numbers |
|
|
|
|
|
|
|
|
|
Some other explanation about the subtract function. |
|
|
|
|
)pbdoc"); |
|
|
|
|
|
|
|
|
|
#ifdef VERSION_INFO |
|
|
|
|
m.attr("__version__") = py::str(VERSION_INFO); |
|
|
|
|
m.attr("__version__") = VERSION_INFO; |
|
|
|
|
#else |
|
|
|
|
m.attr("__version__") = py::str("dev"); |
|
|
|
|
m.attr("__version__") = "dev"; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
return m.ptr(); |
|
|
|
|
} |
|
|
|
|