Files
ports/math/py-numpy1/files/patch-numpy_lib_utils.py
T
Charlie Li 28081ef832 math/py-numpy1: backport configtool/pkg-config file from numpy 2
Traditionally the way to query for the numpy C API has been through
distutils/setuptools, but the use of setuptools beyond a PEP-517
build backend is increasingly discouraged. numpy 2 introduced
numpy-config and a pkg-config file to allow consumer build systems
to better support the use of numpy as a dependency.

Based on: https://github.com/numpy/numpy/commit/2634f803313f349170c09606d3cc619accd72247

Reported by: fluffy
PR: 281470
2026-04-03 21:47:26 -04:00

36 lines
1.2 KiB
Python

--- numpy/lib/utils.py.orig 2024-02-05 21:17:48 UTC
+++ numpy/lib/utils.py
@@ -76,18 +76,29 @@ def get_include():
"""
Return the directory that contains the NumPy \\*.h header files.
- Extension modules that need to compile against NumPy should use this
+ Extension modules that need to compile against NumPy may need to use this
function to locate the appropriate include directory.
Notes
-----
- When using ``distutils``, for example in ``setup.py``::
+ When using ``setuptools``, for example in ``setup.py``::
import numpy as np
...
Extension('extension_name', ...
- include_dirs=[np.get_include()])
+ 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
"""
import numpy