File size: 1,744 Bytes
7885a28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
_binary_tree_pxi = custom_target(
  '_binary_tree_pxi',
  output: '_binary_tree.pxi',
  input: '_binary_tree.pxi.tp',
  command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'],
)

# .pyx is generated so this is needed to make Cython compilation work. The pxi
# file is included avoid "missing dependency paths" with ninja -t missindeps
neighbors_cython_tree = [
  fs.copyfile('__init__.py'),
  fs.copyfile('_partition_nodes.pxd'),
  _binary_tree_pxi,
]

name_list = ['_ball_tree', '_kd_tree']

foreach name: name_list
  pyx = custom_target(
    name + '_pyx',
    output: name + '.pyx',
    input: name + '.pyx.tp',
    command: [py, tempita, '@INPUT@', '-o', '@OUTDIR@'],
    # TODO in principle this should go in py.exension_module below. This is
    # temporary work-around for dependency issue with .pyx.tp files. For more
    # details, see https://github.com/mesonbuild/meson/issues/13212
    depends: [neighbors_cython_tree, utils_cython_tree, metrics_cython_tree],
  )
  py.extension_module(
    name,
    pyx,
    dependencies: [np_dep],
    cython_args: cython_args,
    subdir: 'sklearn/neighbors',
    install: true
)
endforeach

neighbors_extension_metadata = {
  '_partition_nodes':
      {'sources': ['_partition_nodes.pyx'],
       'override_options': ['cython_language=cpp'], 'dependencies': [np_dep]},
  '_quad_tree': {'sources': ['_quad_tree.pyx'], 'dependencies': [np_dep]},
}

foreach ext_name, ext_dict : neighbors_extension_metadata
  py.extension_module(
    ext_name,
    [ext_dict.get('sources'), utils_cython_tree],
    dependencies: ext_dict.get('dependencies'),
    override_options : ext_dict.get('override_options', []),
    cython_args: cython_args,
    subdir: 'sklearn/neighbors',
    install: true
  )
endforeach