提交 89fdac36 编写于 作者: X Xiangquan Xiao

Cyber: Implement py_init wrapper for Python3.

上级 5a683b76
......@@ -21,6 +21,26 @@ cc_library(
],
)
cc_binary(
name = "_cyber_init_py3.so",
linkshared = True,
deps = [
":py3_init",
],
)
cc_library(
name = "py3_init",
srcs = ["py_init.cc"],
hdrs = ["py_init.h"],
defines = ["PY_MAJOR_VERSION=3"],
deps = [
"//cyber:cyber_core",
"@fastrtps",
"@python3",
],
)
cc_test(
name = "py_init_test",
srcs = [
......
......@@ -77,10 +77,28 @@ static PyMethodDef _cyber_init_methods[] = {
{"py_is_shutdown", cyber_py_is_shutdown, METH_NOARGS, ""},
{"py_waitforshutdown", cyber_py_waitforshutdown, METH_NOARGS, ""},
{NULL, NULL, 0, NULL} /* sentinel */
{nullptr, nullptr, 0, nullptr} /* sentinel */
};
/// Init function of this module
#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC PyInit___cyber_init_py3(void) {
static struct PyModuleDef _cyber_init_module_def = {
PyModuleDef_HEAD_INIT,
"_cyber_init_py3", // Module name.
"CyberInit module", // Module doc.
-1, // Module size.
_cyber_init_methods, // Module methods.
nullptr,
nullptr,
nullptr,
nullptr,
};
return PyModule_Create(&_cyber_init_module_def);
}
#else
PyMODINIT_FUNC init_cyber_init(void) {
Py_InitModule("_cyber_init", _cyber_init_methods);
}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册