Skip to content

Commit d79cb58

Browse files
lestevejeremiedbb
andauthored
BLD Check build dependencies in meson.build (scikit-learn#28721)
Co-authored-by: Jérémie du Boisberranger <jeremie@probabl.ai>
1 parent bed36b2 commit d79cb58

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ all:
1414
dev: dev-meson
1515

1616
dev-meson:
17-
pip install --verbose --no-build-isolation --editable . --check-build-dependencies --config-settings editable-verbose=true
17+
pip install --verbose --no-build-isolation --editable . --config-settings editable-verbose=true
1818

1919
clean: clean-meson
2020

doc/developers/advanced_installation.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ feature, code or documentation improvement).
9999

100100
pip install --editable . \
101101
--verbose --no-build-isolation \
102-
--check-build-dependencies \
103102
--config-settings editable-verbose=true
104103

105104
#. Check that the installed scikit-learn has a version number ending with

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
@@ -98,7 +98,7 @@ build-backend = "mesonpy"
9898
requires = [
9999
"meson-python>=0.16.0",
100100
"Cython>=3.0.10",
101-
"numpy>=1.25",
101+
"numpy>=2",
102102
"scipy>=1.6.0",
103103
]
104104

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)