forked from scikit-learn/scikit-learn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
107 lines (95 loc) · 3.17 KB
/
Copy pathmeson.build
File metadata and controls
107 lines (95 loc) · 3.17 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
project(
'scikit-learn',
'c', 'cpp', 'cython',
version: run_command('sklearn/_build_utils/version.py', check: true).stdout().strip(),
license: 'BSD-3',
meson_version: '>= 1.1.0',
default_options: [
'c_std=c11',
'cpp_std=c++14',
],
)
aarch64_variant = ''
openmp_variant = ''
x86_64_variant = ''
foreach variant_meta : get_option('variant')
split_meta = variant_meta.split('::')
if split_meta.length() != 3
error('Invalid variant key: ' + variant_meta)
endif
if split_meta[0].strip() == 'openmp' and split_meta[1].strip() == 'provider'
openmp_variant = split_meta[2].strip()
elif split_meta[0].strip() == 'x86_64' and split_meta[1].strip() == 'level'
if host_machine.cpu_family() != 'x86_64'
error('Variant valid only on x86_64: ' + variant_meta)
endif
x86_64_variant = split_meta[2].strip()
elif split_meta[0].strip() == 'aarch64' and split_meta[1].strip() == 'version'
if host_machine.cpu_family() != 'aarch64'
error('Variant valid only on aarch64: ' + variant_meta)
endif
aarch64_variant = split_meta[2].strip()
else
error('Unsupported variant key: ' + variant_meta)
endif
endforeach
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
cython = meson.get_compiler('cython')
# Check compiler is recent enough (see "Toolchain Roadmap" for details)
if cc.get_id() == 'gcc'
if not cc.version().version_compare('>=8.0')
error('scikit-learn requires GCC >= 8.0')
endif
elif cc.get_id() == 'msvc'
if not cc.version().version_compare('>=19.20')
error('scikit-learn requires at least vc142 (default with Visual Studio 2019) ' + \
'when building with MSVC')
endif
endif
_global_c_args = cc.get_supported_arguments(
'-Wno-unused-but-set-variable',
'-Wno-unused-function',
'-Wno-conversion',
'-Wno-misleading-indentation',
)
add_project_arguments(_global_c_args, language : 'c')
# We need -lm for all C code (assuming it uses math functions, which is safe to
# assume for scikit-learn). For C++ it isn't needed, because libstdc++/libc++ is
# guaranteed to depend on it.
m_dep = cc.find_library('m', required : false)
if m_dep.found()
add_project_link_arguments('-lm', language : 'c')
endif
tempita = find_program('sklearn/_build_utils/tempita.py')
py = import('python').find_installation(pure: false)
if x86_64_variant != '' or aarch64_variant != ''
if x86_64_variant != ''
variant_arch = 'x86_64'
variant_value = x86_64_variant
else
variant_arch = 'aarch64'
variant_value = aarch64_variant
endif
lang_mapping = {
'c': 'c',
'cpp': 'c++',
}
foreach meson_lang, plugin_lang : lang_mapping
cpu_flags = run_command(
py, 'get_cpu_flags.py',
'--arch', variant_arch,
'--language', plugin_lang,
'--compiler-name', cc.get_id(),
'--compiler-version', cc.version(),
'--variant', variant_value,
capture: true,
check: true,
).stdout().split()
add_project_arguments(cpu_flags, language: [meson_lang])
endforeach
endif
# Copy all the .py files to the install dir, rather than using
# py.install_sources and needing to list them explicitly one by one
install_subdir('sklearn', install_dir: py.get_install_dir())
subdir('sklearn')