diff --git a/WORKSPACE b/WORKSPACE index 522e24092..0db02611f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -310,4 +310,27 @@ cc_library( hdrs = glob(["**/*.h"]) ) """ -) \ No newline at end of file +) + +# 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") \ No newline at end of file diff --git a/mediapipe/examples/desktop/BUILD b/mediapipe/examples/desktop/BUILD index 8612979d5..fb2c4f3dc 100644 --- a/mediapipe/examples/desktop/BUILD +++ b/mediapipe/examples/desktop/BUILD @@ -89,4 +89,13 @@ 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" + ] ) \ No newline at end of file diff --git a/mediapipe/examples/desktop/cameravtuber_pybind.cc b/mediapipe/examples/desktop/cameravtuber_pybind.cc new file mode 100644 index 000000000..6638acb13 --- /dev/null +++ b/mediapipe/examples/desktop/cameravtuber_pybind.cc @@ -0,0 +1,35 @@ +#include + +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 +} \ No newline at end of file