How do I properly include cython source files in a python meson project managed by the meson build system?
How do I properly include cython source files in a python meson project managed by the meson build system?
Cython as a first class language is still in progress (I'm the author of that work), right now the right way is with a generator or custom target, then compile an extension module:
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
)
Here's an example from the meson test suite, which is pretty close to my example above.
EDIT: cython as a first class language has landed. So if you can rely on Meson 0.59.0, you can just do:
import('python').find_installation().extension_module(
'my_extension_module'
'cython_file.pyx',
install : true
)
The simplest way I found (completely code-side) was to add them like any other source file and when you need to import them in a python file
just add
from pyximport import install
install(language_level=3)
before importing.
Best way is @dcbaker's though. I wrote an example pygobject cython application to show that here.