Add 'xo-pyutil/' from commit 'a2cb8ae60f'
git-subtree-dir: xo-pyutil git-subtree-mainline:219038c445git-subtree-split:a2cb8ae60f
This commit is contained in:
commit
707562f1f2
11 changed files with 347 additions and 0 deletions
1
xo-pyutil/example/CMakeLists.txt
Normal file
1
xo-pyutil/example/CMakeLists.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
add_subdirectory(ex1)
|
||||
11
xo-pyutil/example/ex1/CMakeLists.txt
Normal file
11
xo-pyutil/example/ex1/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# xo-pyutil/example/ex1/CMakeLists.txt
|
||||
|
||||
set(SELF_LIB xo_pyutilexample)
|
||||
set(SELF_SRCS pyex1.cpp)
|
||||
|
||||
if (XO_ENABLE_EXAMPLES)
|
||||
xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS})
|
||||
xo_pybind11_dependency(${SELF_LIB} refcnt)
|
||||
endif()
|
||||
|
||||
# end CMakeLists.txt
|
||||
14
xo-pyutil/example/ex1/pyex1.cpp
Normal file
14
xo-pyutil/example/ex1/pyex1.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* @file pyex1.cpp */
|
||||
|
||||
#include "pyutilexample.hpp"
|
||||
#include "xo/pyutil/pyutil.hpp"
|
||||
#include <cmath>
|
||||
|
||||
namespace xo {
|
||||
|
||||
PYBIND11_MODULE(XO_PYUTILEXAMPLE_MODULE_NAME(), m) {
|
||||
m.def("sqrt", [](double x) { return ::sqrt(x); });
|
||||
}
|
||||
}
|
||||
|
||||
/* end pyex1.cpp */
|
||||
21
xo-pyutil/example/ex1/pyutilexample.hpp.in
Normal file
21
xo-pyutil/example/ex1/pyutilexample.hpp.in
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* @file pyutilexample.hpp */
|
||||
|
||||
/* python requires module name = library name
|
||||
* example:
|
||||
* PYBIND11_MODULE(XO_PYUTILEXAMPLE_MODULE_NAME(), m) { ... }
|
||||
*/
|
||||
#define XO_PYUTILEXAMPLE_MODULE_NAME() @SELF_LIB@
|
||||
|
||||
/* example:
|
||||
* py::module_::import(XO_PYUTILEXAMPLE_MODULE_NAME_STR)
|
||||
*/
|
||||
#define XO_PYUTILEXAMPLE_MODULE_NAME_STR "@SELF_LIB@"
|
||||
|
||||
/* example:
|
||||
* XO_PYUTILEXAMPLE_IMPORT_MODULE()
|
||||
* replaces
|
||||
* py::module_::import("xo_pyexpression")
|
||||
*/
|
||||
#define XO_PYUTILEXAMPLE_IMPORT_MODULE() py::module_::import("@SELF_LIB@")
|
||||
|
||||
/* end pyutilexample.hpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue