Added pybind base.
This commit is contained in:
		
							parent
							
								
									0a41fbc376
								
							
						
					
					
						commit
						46d914e9a4
					
				
							
								
								
									
										23
									
								
								WORKSPACE
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								WORKSPACE
									
									
									
									
									
								
							| 
						 | 
					@ -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")
 | 
				
			||||||
| 
						 | 
					@ -90,3 +90,12 @@ cc_binary(
 | 
				
			||||||
    copts = ["-Iexternal/python_dev", "-DPIC", "-shared", "-fPIC"],
 | 
					    copts = ["-Iexternal/python_dev", "-DPIC", "-shared", "-fPIC"],
 | 
				
			||||||
    linkopts = ["-lboost_python3"]
 | 
					    linkopts = ["-lboost_python3"]
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pybind_extension(
 | 
				
			||||||
 | 
					    name = "cameravtuber2",
 | 
				
			||||||
 | 
					    srcs = [
 | 
				
			||||||
 | 
					        "cameravtuber_pybind.cc"
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										35
									
								
								mediapipe/examples/desktop/cameravtuber_pybind.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								mediapipe/examples/desktop/cameravtuber_pybind.cc
									
									
									
									
									
										Normal 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user