initial commit
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# Xmake cache
|
||||
.xmake/
|
||||
build/
|
||||
dist
|
||||
|
||||
# MacOS Cache
|
||||
.DS_Store
|
||||
|
||||
# VsCode
|
||||
.vscode
|
||||
16
README.md
Normal file
16
README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# pybind11 example
|
||||
|
||||
## Building
|
||||
|
||||
```sh
|
||||
xrepo env python -m pip install build
|
||||
xrepo env python -m build -w
|
||||
```
|
||||
|
||||
Wheels are built in the `dist` directory:
|
||||
|
||||
```sh
|
||||
$ ls dist
|
||||
example-0.0.1-cp313-cp313-linux_x86_64.whl
|
||||
$ pip install dist/xmake_test-0.0.1-cp313-cp313-linux_x86_64.whl
|
||||
```
|
||||
13
pyproject.toml
Normal file
13
pyproject.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[build-system]
|
||||
requires = ["xmake-python >= 0.1.7"]
|
||||
build-backend = "xmake_python"
|
||||
|
||||
[project]
|
||||
name = 'example'
|
||||
version = '0.0.1'
|
||||
description = 'example for pybind11'
|
||||
readme = 'README.md'
|
||||
|
||||
[tool.xmake.xmaker]
|
||||
# https://github.com/xmake-io/xmake/issues/4537
|
||||
command = "--policies=package.include_external_headers:n"
|
||||
38
src/example.cpp
Normal file
38
src/example.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
||||
|
||||
int add(int i, int j) {
|
||||
return i + j;
|
||||
}
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
PYBIND11_MODULE(example, m) {
|
||||
m.doc() = R"pbdoc(
|
||||
Pybind11 example plugin
|
||||
-----------------------
|
||||
.. currentmodule:: example
|
||||
.. autosummary::
|
||||
:toctree: _generate
|
||||
add
|
||||
subtract
|
||||
)pbdoc";
|
||||
|
||||
m.def("add", &add, R"pbdoc(
|
||||
Add two numbers
|
||||
Some other explanation about the add function.
|
||||
)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__") = MACRO_STRINGIFY(VERSION_INFO);
|
||||
#else
|
||||
m.attr("__version__") = "dev";
|
||||
#endif
|
||||
}
|
||||
9
xmake.lua
Normal file
9
xmake.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
add_rules("mode.release", "mode.debug")
|
||||
add_requires("python 3.12.3", "pybind11")
|
||||
|
||||
target("example")
|
||||
set_prefixdir("$(prefixdir)/$(pythondir)", { libdir = "" })
|
||||
add_rules("python.module")
|
||||
add_files("src/*.cpp")
|
||||
add_packages("pybind11")
|
||||
set_languages("c++11")
|
||||
Reference in New Issue
Block a user