Skip to content

Commit

Permalink
BLD Check build dependencies in meson.build (scikit-learn#28721)
Browse files Browse the repository at this point in the history
Co-authored-by: Jérémie du Boisberranger <[email protected]>
  • Loading branch information
lesteve and jeremiedbb authored Jul 15, 2024
1 parent bed36b2 commit d79cb58
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ all:
dev: dev-meson

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

clean: clean-meson

Expand Down
1 change: 0 additions & 1 deletion doc/developers/advanced_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ feature, code or documentation improvement).

pip install --editable . \
--verbose --no-build-isolation \
--check-build-dependencies \
--config-settings editable-verbose=true

#. Check that the installed scikit-learn has a version number ending with
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ project(

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'
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ build-backend = "mesonpy"
requires = [
"meson-python>=0.16.0",
"Cython>=3.0.10",
"numpy>=1.25",
"numpy>=2",
"scipy>=1.6.0",
]

Expand Down
35 changes: 35 additions & 0 deletions sklearn/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,41 @@ if is_mingw
add_project_arguments('-mlong-double-64', language: 'c')
endif

# Only check build dependencies version when not cross-compiling, as running
# Python interpreter can be tricky in cross-compilation settings. For more
# details, see https://docs.scipy.org/doc/scipy/building/cross_compilation.html
if not meson.is_cross_build()
if not py.version().version_compare('>=3.9')
error('scikit-learn requires Python>=3.9, got ' + py.version() + ' instead')
endif

cython_min_version = run_command(py, ['_min_dependencies.py', 'cython'], check: true).stdout().strip()
if not cython.version().version_compare('>=' + cython_min_version)
error('scikit-learn requires Cython>=' + cython_min_version + ', got ' + cython.version() + ' instead')
endif

meson_python_version = run_command(py,
['-c', 'import mesonpy; print(mesonpy.__version__)'], check: true).stdout().strip()
meson_python_min_version = run_command(py, ['_min_dependencies.py', 'meson-python'], check: true).stdout().strip()
if not meson_python_version.version_compare('>=' + meson_python_min_version)
error('scikit-learn requires meson-python>=' + meson_python_min_version + ', got ' + meson_python_version + ' instead')
endif

numpy_version = run_command(py,
['-c', 'import numpy; print(numpy.__version__)'], check: true).stdout().strip()
numpy_min_version = run_command(py, ['_min_dependencies.py', 'numpy'], check: true).stdout().strip()
if not numpy_version.version_compare('>=' + numpy_min_version)
error('scikit-learn requires numpy>=' + numpy_min_version + ', got ' + numpy_version + ' instead')
endif

scipy_version = run_command(py,
['-c', 'import scipy; print(scipy.__version__)'], check: true).stdout().strip()
scipy_min_version = run_command(py, ['_min_dependencies.py', 'scipy'], check: true).stdout().strip()
if not scipy_version.version_compare('>=' + scipy_min_version)
error('scikit-learn requires scipy>=' + scipy_min_version + ', got ' + scipy_version + ' instead')
endif
endif

# Adapted from scipy, each project seems to have its own tweaks for this. One
# day using dependency('numpy') will be a thing, see
# https://github.com/mesonbuild/meson/issues/9598.
Expand Down

0 comments on commit d79cb58

Please sign in to comment.