From 04acd24d81816c3e59da724e8838d314752b0c73 Mon Sep 17 00:00:00 2001 From: azban Date: Sat, 28 Mar 2026 11:22:22 -0600 Subject: [PATCH] python3Packages.numpy: support old CPUs for 2.4.0+ numpy introduced changes that cause import failures for x86_64 machines without x86-64-v2+ features. This change specifies that there is no baseline CPU target featureset, and fixes imports for older CPUs while maintaining optimimized codepaths for newer CPUs. Co-authored-by: Doron Behar --- pkgs/development/python-modules/numpy/2.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/development/python-modules/numpy/2.nix b/pkgs/development/python-modules/numpy/2.nix index 4586642e4219..2b4a4ca177e6 100644 --- a/pkgs/development/python-modules/numpy/2.nix +++ b/pkgs/development/python-modules/numpy/2.nix @@ -63,6 +63,22 @@ buildPythonPackage (finalAttrs: { --replace-fail '/bin/true' '${lib.getExe' coreutils "true"}' ''; + mesonFlags = [ + # This is required to support CPUs with feature-sets earlier than x86-64-v2 + # (before 2009). This will still build optimizations for newer features, but + # allow for importing with older machines. See: + # + # - https://github.com/NixOS/nixpkgs/issues/496822 + # - https://numpy.org/devdocs/reference/simd/build-options.html + # - https://github.com/numpy/numpy/issues/31073 + # + # NOTE: It is possible to enable CPU features based upon attributes defined + # in `lib/systems/architectures.nix`, but that might trigger tons of + # rebuilds on old x86_64 CPU machines, and it will be too complex for + # maintenance. + (lib.mesonOption "cpu-baseline" "none") + ]; + build-system = [ cython gfortran