1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
---
title: Cython
short-description: Support for Cython in Meson
...
# Cython
Meson provides native support for cython programs starting with version 0.59.0.
This means that you can include it as a normal language, and create targets like
any other supported language:
```meson
lib = static_library(
'foo',
'foo.pyx',
)
```
Generally Cython is most useful when combined with the python module's
extension_module method:
```meson
project('my project', 'cython')
py = import('python').find_installation()
dep_py = py.dependency()
py.extension_module(
'foo',
'foo.pyx',
dependencies : dep_py,
)
```
You can pass arguments accepted by the `cython` CLI script with the
`cython_args` argument:
```meson
py.extension_module(
'foo-bounds'
'foo.pyx',
dependencies : dep_py,
cython_args : ['-Xboundscheck=False'],
)
```
## C++ intermediate support
*(New in 0.60.0)*
An option has been added to control this, called `cython_language`. This can be
either `'c'` or `'cpp'`.
For those coming from setuptools/distutils, they will find two things. First,
meson ignores `# distutils: language = c++` inline directives. Second that Meson
allows options only on a per-target granularity. This means that if you need to mix
cython files being transpiled to C and to C++ you need two targets:
```meson
project('my project', 'cython')
cython_cpp_lib = static_library(
'helper_lib',
'foo_cpp.pyx', # will be transpiled to C++
override_options : ['cython_language=cpp'],
)
py.extension_module(
'foo',
'foo.pyx', # will be transpiled to C
link_with : [cython_cpp_lib],
dependencies : dep_py,
)
```
|