Return the directory that contains the NumPy *.h header files.
Extension modules that need to compile against NumPy may need to use this function to locate the appropriate include directory.
When using setuptools, for example in setup.py:
import numpy as np
...
Extension('extension_name', ...
include_dirs=[np.get_include()])
...
Note that a CLI tool numpy-config was introduced in NumPy 2.0, using that is likely preferred for build systems other than setuptools:
$ numpy-config --cflags -I/path/to/site-packages/numpy/_core/include # Or rely on pkg-config: $ export PKG_CONFIG_PATH=$(numpy-config --pkgconfigdir) $ pkg-config --cflags -I/path/to/site-packages/numpy/_core/include
>>> np.get_include() '.../site-packages/numpy/core/include' # may vary
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.get_include.html