Cross compilation#
Cross compilation is a complex topic, we only add some hopefully helpful hintshere (for now). As of May 2025, cross-compilation with a Meson cross file aswell as cross-compilation based oncrossenv are known to work. Conda-forgeuses the latter method. Cross-compilation withoutcrossenv requires passingbuild options tomesonsetup viameson-python.
All distributions that are known to successfully cross compile NumPy are usingpython-mbuild (pypa/build), but usingpip for that should bepossible as well. Here are links to the NumPy “build recipes” on thosedistros:
See alsoMeson’s documentation on cross compilation to learn what options youmay need to pass to Meson to successfully cross compile.
One possible hiccup is that the build requires running a compiled executable inorder to determine thelongdouble format for the host platform. This may bean obstacle, since it requirescrossenv or QEMU to run the host (cross)Python. To avoid this problem, specify the paths to the relevant directories inyourcross file:
[properties]longdouble_format='IEEE_DOUBLE_LE'
For an example of a cross file needed to cross-compile NumPy, seenumpy#288861.Putting that together, invoking a cross build with such a cross file, looks like:
$python-mbuild--wheel-Csetup-args="--cross-file=aarch64-myos-cross-file.txt"
For more details and the current status around cross compilation, see:
The state of cross compilation in Python:pypackaging-native key issue page
Tracking issue for SciPy cross-compilation needs and issues:scipy#14812