Fix libmkl_umath_loops.so ImportError under meson-python >= 0.22 - #275
Merged
Merged
Conversation
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.
antonwolfy
requested review from
jharlow-intel,
ndgrigorian,
vlad-perevezentsev and
xaleryb
as code owners
September 28, 2026 13:17
jharlow-intel
approved these changes
Sep 28, 2026
jharlow-intel
left a comment
Collaborator
There was a problem hiding this comment.
This looks great, like the RPATH comment added to meson.build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
ImportError: libmkl_umath_loops.so: cannot open shared object fileat import time on Linux/macOS when the package is built withmeson-python>= 0.22, by adding$ORIGIN(the installed package directory) to the extension modules'-Wl,-rpathlink_args.Root cause
libmkl_umath_loops.sois installed into themkl_umathpackage directory, alongside the_ufuncsand_patch_numpyextension modules that link against it. Locating it at import time relied on the$ORIGINRPATH that Meson auto-inserts for internallink_withdependencies.meson-python0.22 changed behavior and now strips the RPATH entries Meson inserts, so that$ORIGINentry disappears from the installed modules and the loader can no longer find the co-located library.This surfaced once conda-forge shipped
meson-python0.22:test_linuxbegan failing atimport mkl_umathacross all Python versions, with no code change.Fix
Add
$ORIGIN(@loader_pathon macOS) torpath_link_argsinmeson.build, next to the existing$ORIGIN/../..and$ORIGIN/../../..entries used for the MKL runtime.Alternatives considered
Migrating to
meson-python'sinstall_rpathargument (see #274) is cleaner but requiresmeson-python>= 0.22, which on conda-forge requires Python >= 3.11 — so it cannot be adopted while the project still builds for Python 3.10. This PR intentionally avoids the floor bump; #274 remains open for when Python 3.10 is dropped.