Added pybind base.

This commit is contained in:
xiong-jie-y 2020-06-21 11:53:56 +09:00
parent 0a41fbc376
commit 46d914e9a4
3 changed files with 68 additions and 1 deletions

View File

@ -311,3 +311,26 @@ cc_library(
)
"""
)
# http_archive(
# name = "pybind11_bazel",
# strip_prefix = "pybind11_bazel-16ed1b8f308d2b3dec9d7e6decaad49ce4d28b43",
# urls = ["https://github.com/pybind/pybind11_bazel/archive/16ed1b8f308d2b3dec9d7e6decaad49ce4d28b43.zip"],
# )
new_local_repository(
name = "pybind11_bazel",
path = "/home/yusuke/gitrepos/pybind11_bazel",
build_file = "BUILD",
)
# We still require the pybind library.
http_archive(
name = "pybind11",
build_file = "@pybind11_bazel//:pybind11.BUILD",
strip_prefix = "pybind11-2.5.0",
urls = ["https://github.com/pybind/pybind11/archive/v2.5.0.tar.gz"],
)
load("@pybind11_bazel//:python_configure.bzl", "python_configure")
python_configure(name = "local_config_python")

View File

@ -90,3 +90,12 @@ cc_binary(
copts = ["-Iexternal/python_dev", "-DPIC", "-shared", "-fPIC"],
linkopts = ["-lboost_python3"]
)
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
pybind_extension(
name = "cameravtuber2",
srcs = [
"cameravtuber_pybind.cc"
]
)

View File

@ -0,0 +1,35 @@
#include <pybind11/pybind11.h>
int add(int i, int j) {
return i + j;
}
namespace py = pybind11;
PYBIND11_MODULE(cameravtuber2, m) {
m.doc() = R"pbdoc(
Pybind11 example plugin
-----------------------
.. currentmodule:: python_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__") = VERSION_INFO;
#else
m.attr("__version__") = "dev";
#endif
}