From fe0bdcd1c6f9ff29fe507f4b2bd16bb6b476e9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Thu, 20 Jul 2023 10:28:02 +0200 Subject: [PATCH 1/2] Revert "python3Packages.numpy: temporarily avoid rebuild on !isClang" This reverts commit 7ea07d2c0c919cb3b49de10e9134d15a449a8ba4. --- pkgs/development/python-modules/numpy/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/numpy/default.nix b/pkgs/development/python-modules/numpy/default.nix index 65a077392ff9..f8bb6c2b2e65 100644 --- a/pkgs/development/python-modules/numpy/default.nix +++ b/pkgs/development/python-modules/numpy/default.nix @@ -39,7 +39,7 @@ let }; }; }; -in buildPythonPackage (rec { +in buildPythonPackage rec { pname = "numpy"; version = "1.24.2"; format = "setuptools"; @@ -91,6 +91,9 @@ in buildPythonPackage (rec { nativeBuildInputs = [ gfortran cython ]; buildInputs = [ blas lapack ]; + # Causes `error: argument unused during compilation: '-fno-strict-overflow'` due to `-Werror`. + hardeningDisable = lib.optionals stdenv.cc.isClang [ "strictoverflow" ]; + # we default openblas to build with 64 threads # if a machine has more than 64 threads, it will segfault # see https://github.com/xianyi/OpenBLAS/issues/2993 @@ -137,7 +140,4 @@ in buildPythonPackage (rec { license = lib.licenses.bsd3; maintainers = with lib.maintainers; [ fridh ]; }; -} // lib.optionalAttrs stdenv.cc.isClang { - # Causes `error: argument unused during compilation: '-fno-strict-overflow'` due to `-Werror`. - hardeningDisable = [ "strictoverflow" ]; -}) +} From f94d2b74f6c11d4f1c72a67046be05bb2c77f917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Thu, 20 Jul 2023 10:34:29 +0200 Subject: [PATCH 2/2] python3Packages.numpy: apply patches unconditionally The test-skipping patch is conditionalized on python layer. I moved the conditional patch after the unconditional ones, too. --- .../python-modules/numpy/default.nix | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/pkgs/development/python-modules/numpy/default.nix b/pkgs/development/python-modules/numpy/default.nix index f8bb6c2b2e65..134dd5c98a3f 100644 --- a/pkgs/development/python-modules/numpy/default.nix +++ b/pkgs/development/python-modules/numpy/default.nix @@ -51,33 +51,31 @@ in buildPythonPackage rec { hash = "sha256-ADqfUw6IDLLNF3y6GvciC5qkLe+cSvwqL8Pua+frKyI="; }; - patches = lib.optionals python.hasDistutilsCxxPatch [ - # We patch cpython/distutils to fix https://bugs.python.org/issue1222585 - # Patching of numpy.distutils is needed to prevent it from undoing the - # patch to distutils. - ./numpy-distutils-C++.patch - ] - ++ lib.optionals stdenv.cc.isClang [ + patches = [ # f2py.f90mod_rules generates code with invalid function pointer conversions, which are # clang 16 makes an error by default. (fetchpatch { url = "https://github.com/numpy/numpy/commit/609fee4324f3521d81a3454f5fcc33abb0d3761e.patch"; hash = "sha256-6Dbmf/RWvQJPTIjvchVaywHGcKCsgap/0wAp5WswuCo="; }) - ] - ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ + # Backport from 1.25. `platform.machine` returns `arm64` on aarch64-darwin, which causes # differing results between `_selected_real_kind_func` and Fortran’s `selected_real_kind`. (fetchpatch { url = "https://github.com/numpy/numpy/commit/afcedf4b63f4a94187e6995c2adea0da3bb18e83.patch"; hash = "sha256-cxBoimX5a9wC2qUIGAo5o/M2E9+eV63bV2/wLmfDYKg="; }) - ] - ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ + # Disable `numpy/core/tests/test_umath.py::TestComplexFunctions::test_loss_of_precision[complex256]` # on x86_64-darwin because it fails under Rosetta 2 due to issues with trig functions and # 80-bit long double complex numbers. ./disable-failing-long-double-test-Rosetta-2.patch + ] + # We patch cpython/distutils to fix https://bugs.python.org/issue1222585 + # Patching of numpy.distutils is needed to prevent it from undoing the + # patch to distutils. + ++ lib.optionals python.hasDistutilsCxxPatch [ + ./numpy-distutils-C++.patch ]; postPatch = ''