如何在python介子管理的项目中包含cython文件?
如何在介子构建系统管理的 python 介子项目中正确包含 cython 源文件?
回答
Cython 作为一流的语言仍在开发中(我是这项工作的作者),现在正确的方法是使用生成器或自定义目标,然后编译扩展模块:
pyx_c = custom_target(
'cython_file.c',
output : 'cython_file.c',
input : 'cython_file.pyx',
command : [cython, '@INPUT@', '-o', '@OUTPUT@'],
)
import('python').find_installation().extension_module(
'my_extension_module'
pyx_c,
install : true
)
这是介子测试套件中的一个示例,它与我上面的示例非常接近。
编辑:cython 作为一流的语言已经登陆。因此,如果您可以依靠 Meson 0.59.0,您可以这样做:
import('python').find_installation().extension_module(
'my_extension_module'
'cython_file.pyx',
install : true
)