diff --git a/.gitignore b/.gitignore index e257658..0934ef9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +build +.vscode # ---> C++ # Prerequisites *.d diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4ec5702 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.15) +set(PYBIND11_FINDPYTHON ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +project(test_pybind11 VERSION 1.0 DESCRIPTION "a default project" LANGUAGES CXX) +find_package(pybind11 REQUIRED) +pybind11_add_module(${PROJECT_NAME} main.cpp) diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..3062176 --- /dev/null +++ b/main.cpp @@ -0,0 +1,17 @@ +#include +#include + +int add(int i, int j) { + return i + j; +} + +std::vector sort_num(std::vector array){ + std::sort(array.begin(),array.end()); + return array; +} + +PYBIND11_MODULE(test_pybind11, m) { + m.doc() = "pybind11 example plugin"; // optional module docstring + m.def("sort_num",&sort_num,"A function to sort INT numbers"); + m.def("add", &add, "A function that adds two numbers"); +} \ No newline at end of file diff --git a/make.py b/make.py new file mode 100644 index 0000000..48e0a5b --- /dev/null +++ b/make.py @@ -0,0 +1,12 @@ +from pymake import * + + +( + cmake("3.15") + .set("PYBIND11_FINDPYTHON", on) + .set(cmake_export_compile_commands, on) + .project("test_pybind11") + .find_package("pybind11","REQUIRED") + .pybind11_add_module(var(project_name),"main.cpp") + .write() +) \ No newline at end of file