我一直在用cython的hello world例子做一些测试,其中包括 scikit-build-sample-projects(示例项目)我注意到,如果我改变CMakeLists.txt中的一些文件名和相应的字段,编译工作就不会出错,但当尝试编译结果时,会出现以下错误。
对于python3:ImportError: dynamic module does not define module export function (PyInit_...
对于python2:ImportError: dynamic module does not define module export function (Init_...
再看一下 c++文件 我发现了这些部分,如果我把"_hello "部分改成我在项目中定义的新名字,一切都能正常工作。
#if PY_MAJOR_VERSION < 3
PyMODINIT____FUNC init_hello(void)
{
(void) Py_InitModule("_rectangle", hello_methods);
}
#else /* PY_MAJOR_VERSION >= 3 */
static struct PyModuleDef hello_module_def = {
PyModuleDef_HEAD_INIT,
"_rectangle",
"Internal \"_rectangle\" module",
-1,
hello_methods
};
PyMODINIT_FUNC PyInit__rectangle(void)
{
return PyModule_Create(&hello_module_def);
}
#endif /* PY_MAJOR_VERSION >= 3 */
如果我把"_hello "部分改成我在项目中定义的新名字 一切都能正常工作了
现在我想试试 原Cython的矩形类示例 并不知道如何使它工作,因为上面的部分。在我看来,我应该修改rectangle的c++代码。
有谁知道如何在考虑到上述问题的前提下,用scikit build重现Cython的rectangle例子?