codekingpro/portable-devtools
114k
1project(
2 'checks',
3 'c', 'cython',
4 meson_version: '>=1.8.3',
5)
6
7py = import('python').find_installation(pure: false)
8
9cc = meson.get_compiler('c')
10cy = meson.get_compiler('cython')
11
12# Keep synced with pyproject.toml
13if not cy.version().version_compare('>=3.0.6')
14 error('tests requires Cython >= 3.0.6')
15endif
16
17npy_include_path = run_command(py, [
18 '-c',
19 'import os; os.chdir(".."); import numpy; print(os.path.abspath(numpy.get_include()))'
20 ], check: true).stdout().strip()
21
22npy_path = run_command(py, [
23 '-c',
24 'import os; os.chdir(".."); import numpy; print(os.path.dirname(numpy.__file__).removesuffix("numpy"))'
25 ], check: true).stdout().strip()
26
27# TODO: This is a hack due to https://github.com/cython/cython/issues/5820,
28# where cython may not find the right __init__.pyd file.
29add_project_arguments('-I', npy_path, language : 'cython')
30
31py.extension_module(
32 'limited_api1',
33 'limited_api1.c',
34 c_args: [
35 '-DNPY_NO_DEPRECATED_API=NPY_1_21_API_VERSION',
36 ],
37 include_directories: [npy_include_path],
38 limited_api: '3.9',
39)
40
41py.extension_module(
42 'limited_api_latest',
43 'limited_api_latest.c',
44 c_args: [
45 '-DNPY_NO_DEPRECATED_API=NPY_1_21_API_VERSION',
46 ],
47 include_directories: [npy_include_path],
48 limited_api: py.language_version(),
49)
50
51py.extension_module(
52 'limited_api2',
53 'limited_api2.pyx',
54 install: false,
55 c_args: [
56 '-DNPY_NO_DEPRECATED_API=0',
57 # Require 1.25+ to test datetime additions
58 '-DNPY_TARGET_VERSION=NPY_2_0_API_VERSION',
59 '-DCYTHON_LIMITED_API=1',
60 ],
61 include_directories: [npy_include_path],
62 limited_api: '3.9',
63)
64 