update
This commit is contained in:
parent
24ba2be085
commit
d2bab3232d
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
build
|
||||
.vscode
|
||||
# ---> C++
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
7
CMakeLists.txt
Normal file
7
CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
project(test_pybind11 VERSION 1.0 DESCRIPTION "a default project" LANGUAGES CXX)
|
||||
file(GLOB_RECURSE SRC src/*.cpp)
|
||||
find_package(Python 3.12.3 COMPONENTS Interpreter Development REQUIRED)
|
||||
find_package(pybind11 CONFIG REQUIRED)
|
||||
pybind11_add_module(${PROJECT_NAME} ${SRC})
|
13
make.py
Normal file
13
make.py
Normal file
@ -0,0 +1,13 @@
|
||||
from pymake import *
|
||||
|
||||
|
||||
(
|
||||
cmake("3.15")
|
||||
.set(cmake_export_compile_commands, on)
|
||||
.project("test_pybind11")
|
||||
.file("SRC",glob_recurse,"src/*.cpp")
|
||||
.just_add("""find_package(Python 3.12.3 COMPONENTS Interpreter Development REQUIRED)""")
|
||||
.just_add("find_package(pybind11 CONFIG REQUIRED)")
|
||||
.pybind11_add_module(var(project_name),var("SRC"))
|
||||
.write()
|
||||
)
|
17
src/main.cpp
Normal file
17
src/main.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
int add(int i, int j) {
|
||||
return i + j;
|
||||
}
|
||||
|
||||
std::vector<int> sort_num(std::vector<int> 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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user