about summary refs log tree commit diff
path: root/pkgs/development/python-modules/numpy/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/numpy/default.nix')
-rw-r--r--pkgs/development/python-modules/numpy/default.nix159
1 files changed, 85 insertions, 74 deletions
diff --git a/pkgs/development/python-modules/numpy/default.nix b/pkgs/development/python-modules/numpy/default.nix
index c2d38cc31b248..f20bd095cf97f 100644
--- a/pkgs/development/python-modules/numpy/default.nix
+++ b/pkgs/development/python-modules/numpy/default.nix
@@ -1,30 +1,34 @@
-{ lib
-, stdenv
-, fetchPypi
-, python
-, pythonAtLeast
-, pythonOlder
-, buildPythonPackage
-, writeTextFile
-
-# build-system
-, cython
-, gfortran
-, meson-python
-, mesonEmulatorHook
-, pkg-config
-, xcbuild
-
-# native dependencies
-, blas
-, lapack
-
-# tests
-, hypothesis
-, pytest-xdist
-, pytestCheckHook
-, setuptools
-, typing-extensions
+{
+  lib,
+  stdenv,
+  fetchPypi,
+  python,
+  pythonAtLeast,
+  pythonOlder,
+  buildPythonPackage,
+  writeTextFile,
+
+  # build-system
+  cython,
+  gfortran,
+  meson-python,
+  mesonEmulatorHook,
+  pkg-config,
+  xcbuild,
+
+  # native dependencies
+  blas,
+  lapack,
+
+  # Reverse dependency
+  sage,
+
+  # tests
+  hypothesis,
+  pytest-xdist,
+  pytestCheckHook,
+  setuptools,
+  typing-extensions,
 }:
 
 assert (!blas.isILP64) && (!lapack.isILP64);
@@ -32,7 +36,7 @@ assert (!blas.isILP64) && (!lapack.isILP64);
 let
   cfg = writeTextFile {
     name = "site.cfg";
-    text = lib.generators.toINI {} {
+    text = lib.generators.toINI { } {
       ${blas.implementation} = {
         include_dirs = "${lib.getDev blas}/include:${lib.getDev lapack}/include";
         library_dirs = "${blas}/lib:${lapack}/lib";
@@ -51,7 +55,8 @@ let
       };
     };
   };
-in buildPythonPackage rec {
+in
+buildPythonPackage rec {
   pname = "numpy";
   version = "1.26.4";
   pyproject = true;
@@ -63,18 +68,17 @@ in buildPythonPackage rec {
     hash = "sha256-KgKrqe0S5KxOs+qUIcQgMBoMZGDZgw10qd+H76SRIBA=";
   };
 
-  patches = [
-    # 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
-  ];
+  patches =
+    [
+      # 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 = ''
     # fails with multiple errors because we are not using the pinned setuptools version
@@ -93,16 +97,15 @@ in buildPythonPackage rec {
       --replace-fail "meson-python>=0.15.0,<0.16.0" "meson-python"
   '';
 
-  nativeBuildInputs = [
-    cython
-    gfortran
-    meson-python
-    pkg-config
-  ] ++ lib.optionals (stdenv.isDarwin) [
-    xcbuild.xcrun
-  ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
-    mesonEmulatorHook
-  ];
+  nativeBuildInputs =
+    [
+      cython
+      gfortran
+      meson-python
+      pkg-config
+    ]
+    ++ lib.optionals (stdenv.isDarwin) [ xcbuild.xcrun ]
+    ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ mesonEmulatorHook ];
 
   buildInputs = [
     blas
@@ -145,38 +148,46 @@ in buildPythonPackage rec {
 
   # https://github.com/numpy/numpy/blob/a277f6210739c11028f281b8495faf7da298dbef/numpy/_pytesttester.py#L180
   pytestFlagsArray = [
-    "-m" "not\\ slow" # fast test suite
+    "-m"
+    "not\\ slow" # fast test suite
   ];
 
   # https://github.com/numpy/numpy/issues/24548
-  disabledTests = lib.optionals stdenv.isi686 [
-    "test_new_policy" # AssertionError: assert False
-    "test_identityless_reduction_huge_array" # ValueError: Maximum allowed dimension exceeded
-    "test_float_remainder_overflow" # AssertionError: FloatingPointError not raised by divmod
-    "test_int" # AssertionError: selectedintkind(19): expected 16 but got -1
-  ] ++ lib.optionals stdenv.isAarch32 [
-    "test_impossible_feature_enable" # AssertionError: Failed to generate error
-    "test_features" # AssertionError: Failure Detection
-    "test_new_policy" # AssertionError: assert False
-    "test_identityless_reduction_huge_array" # ValueError: Maximum allowed dimension exceeded
-    "test_unary_spurious_fpexception"#  AssertionError: Got warnings: [<warnings.WarningMessage object at 0xd1197430>]
-    "test_int" # AssertionError: selectedintkind(19): expected 16 but got -1
-    "test_real" # AssertionError: selectedrealkind(16): expected 10 but got -1
-    "test_quad_precision" # AssertionError: selectedrealkind(32): expected 16 but got -1
-    "test_big_arrays" # ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger tha...
-    "test_multinomial_pvals_float32" # Failed: DID NOT RAISE <class 'ValueError'>
-  ] ++ lib.optionals stdenv.isAarch64 [
-    "test_big_arrays" # OOM on a 16G machine
-  ] ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
-    # can fail on virtualized machines confused over their cpu identity
-    "test_dispatcher"
-  ];
+  disabledTests =
+    lib.optionals stdenv.isi686 [
+      "test_new_policy" # AssertionError: assert False
+      "test_identityless_reduction_huge_array" # ValueError: Maximum allowed dimension exceeded
+      "test_float_remainder_overflow" # AssertionError: FloatingPointError not raised by divmod
+      "test_int" # AssertionError: selectedintkind(19): expected 16 but got -1
+    ]
+    ++ lib.optionals stdenv.isAarch32 [
+      "test_impossible_feature_enable" # AssertionError: Failed to generate error
+      "test_features" # AssertionError: Failure Detection
+      "test_new_policy" # AssertionError: assert False
+      "test_identityless_reduction_huge_array" # ValueError: Maximum allowed dimension exceeded
+      "test_unary_spurious_fpexception" # AssertionError: Got warnings: [<warnings.WarningMessage object at 0xd1197430>]
+      "test_int" # AssertionError: selectedintkind(19): expected 16 but got -1
+      "test_real" # AssertionError: selectedrealkind(16): expected 10 but got -1
+      "test_quad_precision" # AssertionError: selectedrealkind(32): expected 16 but got -1
+      "test_big_arrays" # ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger tha...
+      "test_multinomial_pvals_float32" # Failed: DID NOT RAISE <class 'ValueError'>
+    ]
+    ++ lib.optionals stdenv.isAarch64 [
+      "test_big_arrays" # OOM on a 16G machine
+    ]
+    ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
+      # can fail on virtualized machines confused over their cpu identity
+      "test_dispatcher"
+    ];
 
   passthru = {
     # just for backwards compatibility
     blas = blas.provider;
     blasImplementation = blas.implementation;
     inherit cfg;
+    tests = {
+      inherit sage;
+    };
   };
 
   # Disable test