From 95d2a3227bcc8a589ad2a908dc1f94b605fc8cca Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 22 Jun 2026 14:47:48 +0300 Subject: [PATCH] python3Packages.numpy: make numpy.pc more visible This change also enables scipy to find numpy via pkg-config, and not only via `scipy.passthru.buildConfig.properties.numpy-include-dir`, and thus enables free threading via f2py. See: https://github.com/scipy/scipy/commit/7fd20c742b74264e7c75e86292b7b8748a63d53c#diff-b39b7bda5a39c101be8d9e0b3b6d4da335b6daf7385c2a43463125b0a1f33778 Arguably, this makes the `numpy.passthru.coreIncludeDir` definition redundant, but we will keep it for backwards compatibility. --- pkgs/development/python-modules/numpy/2.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/numpy/2.nix b/pkgs/development/python-modules/numpy/2.nix index 1a5eaecaa010..6849c82285c0 100644 --- a/pkgs/development/python-modules/numpy/2.nix +++ b/pkgs/development/python-modules/numpy/2.nix @@ -113,6 +113,14 @@ buildPythonPackage (finalAttrs: { typing-extensions ]; + # Enables any dependent package to easily find numpy.pc via standard + # pkg-config call. The `$out/include` symlink matches what's written in the + # numpy.pc file. + postInstall = '' + ln -s $out/${python.sitePackages}/numpy/_core/lib/pkgconfig $out/lib/pkgconfig + ln -s ${placeholder "out"}/${finalAttrs.passthru.coreIncludeInnerDir} $out/include + ''; + preCheck = '' pushd $out # For numpy-config executable to be available during tests @@ -192,7 +200,11 @@ buildPythonPackage (finalAttrs: { name = "site.cfg"; text = lib.generators.toINI { } finalAttrs.finalPackage.buildConfig; }; - coreIncludeDir = "${finalAttrs.finalPackage}/${python.sitePackages}/numpy/_core/include"; + # Need to be defined with two variables for postInstall to use `placeholder + # "out"` where here we have to use `${finalAttrs.finalPackage}`, that would + # cause infinite recursion if used in postInstall too. + coreIncludeInnerDir = "${python.sitePackages}/numpy/_core/include"; + coreIncludeDir = "${finalAttrs.finalPackage}/${finalAttrs.finalPackage.passthru.coreIncludeInnerDir}"; tests = { inherit sage; };