Cross compilation#

Cross compilation is a complex topic, we only add some hopefully helpful hints here (for now). As of May 2023, cross-compilation based on crossenv is known to work, as used (for example) in conda-forge. Cross-compilation without crossenv requires some manual overrides. You instruct these overrides by passing options to meson setup via meson-python.

All distributions that are known to successfully cross compile SciPy are using python -m build (pypa/build), but using pip for that should be possible as well. Here are links to the SciPy’s “build recipes” on those distros:

See also Meson’s documentation on cross compilation to learn what options you may need to pass to Meson to successfully cross compile.

One common hiccup is that pythran requires running Python code in order to obtain its include directory. This tends to not work well, either accidentally picking up the packages from the build (native) Python rather than the host (cross) Python or requiring crossenv or QEMU to run the host Python. To avoid this problem, specify the path to the relevant directory in your cross file:

[constants]
sitepkg = '/abspath/to/host-pythons/site-packages/'

[properties]
pythran-include-dir = sitepkg + 'pythran'

numpy used to require the same treatment, through a numpy-include-dir property. That is no longer needed: since SciPy 2.0.0 (when f2py was removed) nothing needs a path to numpy’s headers directly, so numpy is looked up with Meson’s dependency('numpy'). Meson resolves that through a numpy.pc pkg-config file if it can find one, and otherwise by running the numpy-config executable. For a cross build, provide a numpy.pc for the numpy you are targeting; it takes precedence over a numpy in the build environment.

For more details and the current status around cross compilation, see: