So I would like to build numpy against MKL BLAS on Ubuntu 20.04.
I have no trouble building and linking against system installed mkl (from e.g. the Ubuntu intel-mkl package). As documented in site.cfg.example I created a copy site.cfg next to it and filled in the relevant information
[mkl]
library_dirs = /path/to/my/local/mkl/lib
include_dirs = /path/to/my/local/mkl/include
libraries = mkl_rt
I can create a wheel with python -m build --wheel that is linked against that MKL, I can install it fine with pip install my_numpy.whl and after import numpy, numpy.show_config() shows the expected info regarding mkl.
Now what I would like to do is to be independent from
- system installed mkl
- absolute paths in
library_dirsandinclude_dirs
All the necessary library and include files for building and linking against MKL are available in the PyPI packages mkl and mkl-include. I would like to configure a build process, where these two packages are downloaded, built and linked against and also added to the requirements. Now I understand running python3 -m build creates a separate venv and preinstalls any packages listed in pyproject.toml. Here my edited version with mkl and mkl-include added at the bottom
[build-system]
# Minimum requirements for the build system to execute.
requires = [
"packaging==20.5; platform_machine=='arm64'", # macos M1
"setuptools<49.2.0",
"wheel==0.36.2",
"Cython>=0.29.24,<3.0", # Note: keep in sync with tools/cythonize.py
"mkl-include<2021.2",
"mkl<2021.2"
]
I am stuck at what to put into site.cfg under library_dirs and include_dirs to use the files from the packages installed by the build venv. Is there a way to include the current venv's prefix into those paths? If yes, how? Do the numpy.distutils offer anything in that regard?
Or do I have to approach this problem differently? E.g. is there a way to build numpy and create a .whl, but without explicitly linking, s.t. linking can be delayed until actual installation time of the built wheel, where the actual MKL runtime libraries are found (in this case /path/to/my/current/venv/lib) and linked against? Is that even possible with a wheel?
Thanks for your help!