Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2190f04

Browse files
glemaitrejeremiedbb
andcommitted
BLD Check build dependencies in meson.build (#28721)
Co-authored-by: Jérémie du Boisberranger <[email protected]>
1 parent f9a789c commit 2190f04

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ inplace:
2626
dev-meson:
2727
pip install --verbose --no-build-isolation --editable . --config-settings editable-verbose=true
2828

29+
clean: clean-meson
30+
2931
clean-meson:
3032
pip uninstall -y scikit-learn
3133

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ project(
1313

1414
cc = meson.get_compiler('c')
1515
cpp = meson.get_compiler('cpp')
16+
cython = meson.get_compiler('cython')
1617

1718
# Check compiler is recent enough (see "Toolchain Roadmap" for details)
1819
if cc.get_id() == 'gcc'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ build-backend = "mesonpy"
9999
requires = [
100100
"meson-python>=0.16.0",
101101
"Cython>=3.0.10",
102-
"numpy>=2.0.0rc2",
102+
"numpy>=2",
103103
"scipy>=1.6.0",
104104
]
105105

sklearn/meson.build

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,41 @@ if is_mingw
1818
add_project_arguments('-mlong-double-64', language: 'c')
1919
endif
2020

21+
# Only check build dependencies version when not cross-compiling, as running
22+
# Python interpreter can be tricky in cross-compilation settings. For more
23+
# details, see https://docs.scipy.org/doc/scipy/building/cross_compilation.html
24+
if not meson.is_cross_build()
25+
if not py.version().version_compare('>=3.9')
26+
error('scikit-learn requires Python>=3.9, got ' + py.version() + ' instead')
27+
endif
28+
29+
cython_min_version = run_command(py, ['_min_dependencies.py', 'cython'], check: true).stdout().strip()
30+
if not cython.version().version_compare('>=' + cython_min_version)
31+
error('scikit-learn requires Cython>=' + cython_min_version + ', got ' + cython.version() + ' instead')
32+
endif
33+
34+
meson_python_version = run_command(py,
35+
['-c', 'import mesonpy; print(mesonpy.__version__)'], check: true).stdout().strip()
36+
meson_python_min_version = run_command(py, ['_min_dependencies.py', 'meson-python'], check: true).stdout().strip()
37+
if not meson_python_version.version_compare('>=' + meson_python_min_version)
38+
error('scikit-learn requires meson-python>=' + meson_python_min_version + ', got ' + meson_python_version + ' instead')
39+
endif
40+
41+
numpy_version = run_command(py,
42+
['-c', 'import numpy; print(numpy.__version__)'], check: true).stdout().strip()
43+
numpy_min_version = run_command(py, ['_min_dependencies.py', 'numpy'], check: true).stdout().strip()
44+
if not numpy_version.version_compare('>=' + numpy_min_version)
45+
error('scikit-learn requires numpy>=' + numpy_min_version + ', got ' + numpy_version + ' instead')
46+
endif
47+
48+
scipy_version = run_command(py,
49+
['-c', 'import scipy; print(scipy.__version__)'], check: true).stdout().strip()
50+
scipy_min_version = run_command(py, ['_min_dependencies.py', 'scipy'], check: true).stdout().strip()
51+
if not scipy_version.version_compare('>=' + scipy_min_version)
52+
error('scikit-learn requires scipy>=' + scipy_min_version + ', got ' + scipy_version + ' instead')
53+
endif
54+
endif
55+
2156
# Adapted from scipy, each project seems to have its own tweaks for this. One
2257
# day using dependency('numpy') will be a thing, see
2358
# https://github.com/mesonbuild/meson/issues/9598.

0 commit comments

Comments
 (0)