From 649ac3548e60b7bbd0b3edc51e7ec38ac55b1957 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 28 Sep 2026 15:15:06 +0200 Subject: [PATCH] Fix loops library RPATH under meson-python >= 0.22 Add $ORIGIN (the installed package directory) to the -Wl,-rpath link_args so the extension modules can locate the co-located libmkl_umath_loops.so. meson-python >= 0.22 strips the $ORIGIN RPATH Meson auto-inserts for internal link_with dependencies, which caused 'ImportError: libmkl_umath_loops.so: cannot open shared object file' at import time on Linux/macOS. Passing the entry as a raw link_arg (rather than install_rpath) has meson-python preserve it on all supported versions, so the meson-python >= 0.16 floor and Python 3.10 support are unchanged. --- CHANGELOG.md | 1 + meson.build | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a799ed64..14f0aa29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fixed `absolute` (float32/float64) returning `-NaN` for `+NaN` input on the scalar fallback path (same issue as numpy/numpy@dc478c58b9, gh-31433) [gh-269](https://github.com/IntelPython/mkl_umath/pull/269) * Fixed an over-decref of the borrowed module dictionary reference on the module initialization error path [gh-264](https://github.com/IntelPython/mkl_umath/pull/264) * Fixed a leak of the module object when the NumPy C-API import fails during module initialization [gh-263](https://github.com/IntelPython/mkl_umath/pull/263) +* Fixed `ImportError` on Linux/macOS when built with `meson-python` >= 0.22, which strips the `$ORIGIN` RPATH Meson auto-inserts for internal `link_with` dependencies [gh-275](https://github.com/IntelPython/mkl_umath/pull/275) ### Removed * Removed the `python-gil` constraint from the conda recipes, which pinned `mkl_umath` to GIL-enabled Python 3.14 builds [gh-255](https://github.com/IntelPython/mkl_umath/pull/255) diff --git a/meson.build b/meson.build index 6048f493..b162475d 100644 --- a/meson.build +++ b/meson.build @@ -149,6 +149,13 @@ gen_loops_h = custom_target( depends: gen_umath_c ) +# RPATHs for the installed targets, relative to each target's location: +# origin -> the package dir holding libmkl_umath_loops.so, which the +# extension modules link against +# origin/../.. \ the environment library dir, where the MKL runtime lives +# origin/../../.. / +# Passed as raw link_args (not install_rpath) so meson-python preserves them on +# every supported version. Empty on Windows, which has no RPATH concept. rpath_link_args = [] if host_machine.system() != 'windows' if host_machine.system() == 'darwin' @@ -158,6 +165,7 @@ if host_machine.system() != 'windows' endif rpath_link_args = [ + '-Wl,-rpath,' + origin, '-Wl,-rpath,' + origin / '../..', '-Wl,-rpath,' + origin / '../../..', ]