From 7fc80bcd4e5b1a5fb314d08a9a9a054e4ec875bd Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 4 Sep 2023 22:22:42 -0400 Subject: [PATCH 1/2] python3Packages.scipy: support for disabling tests Adapt the logic from pytestCheckHook to the custom check phase used by scipy. Co-authored-by: Doron Behar --- .../python-modules/scipy/default.nix | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/scipy/default.nix b/pkgs/development/python-modules/scipy/default.nix index e58a165f5cca..79d5a6688bb0 100644 --- a/pkgs/development/python-modules/scipy/default.nix +++ b/pkgs/development/python-modules/scipy/default.nix @@ -14,7 +14,7 @@ , pythran , wheel , nose -, pytest +, pytestCheckHook , pytest-xdist , numpy , pybind11 @@ -107,7 +107,11 @@ in buildPythonPackage { __darwinAllowLocalNetworking = true; - nativeCheckInputs = [ nose pytest pytest-xdist ]; + nativeCheckInputs = [ + nose + pytestCheckHook + pytest-xdist + ]; doCheck = !(stdenv.isx86_64 && stdenv.isDarwin); @@ -145,9 +149,38 @@ in buildPythonPackage { checkPhase = '' runHook preCheck + + # Adapted from pytestCheckHook because scipy uses a custom check phase. + # It needs to pass `$args` as a Python list to `scipy.test` rather than as + # arguments to pytest on the command-line. + args="" + if [ -n "$disabledTests" ]; then + disabledTestsString=$(_pytestComputeDisabledTestsString "''${disabledTests[@]}") + args+="'-k','$disabledTestsString'" + fi + + if [ -n "''${disabledTestPaths-}" ]; then + eval "disabledTestPaths=($disabledTestPaths)" + fi + + for path in ''${disabledTestPaths[@]}; do + if [ ! -e "$path" ]; then + echo "Disabled tests path \"$path\" does not exist. Aborting" + exit 1 + fi + args+="''${args:+,}'--ignore=\"$path\"'" + done + args+="''${args:+,}$(printf \'%s\', "''${pytestFlagsArray[@]}")" + args=''${args%,} + pushd "$out" export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 )) - ${python.interpreter} -c "import scipy, sys; sys.exit(scipy.test('fast', verbose=10, parallel=$NIX_BUILD_CORES) != True)" + ${python.interpreter} -c "import scipy, sys; sys.exit(scipy.test( + 'fast', + verbose=10, + extra_argv=[$args], + parallel=$NIX_BUILD_CORES + ) != True)" popd runHook postCheck ''; From 422ef0420f6fe2183b9c20084662a2d9090386b5 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 4 Sep 2023 22:24:46 -0400 Subject: [PATCH 2/2] python3Packages.scipy: disable failing tests on aarch64-darwin Some tests fail on aarch64-darwin when SciPy is built with a newer compiler (such as clang 16). This is not yet fixed upstream, so disable them until they work again. See https://github.com/scipy/scipy/issues/18308 --- pkgs/development/python-modules/scipy/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/development/python-modules/scipy/default.nix b/pkgs/development/python-modules/scipy/default.nix index 79d5a6688bb0..7312e53ed413 100644 --- a/pkgs/development/python-modules/scipy/default.nix +++ b/pkgs/development/python-modules/scipy/default.nix @@ -113,6 +113,17 @@ in buildPythonPackage { pytest-xdist ]; + # The following tests are broken on aarch64-darwin with newer compilers and library versions. + # See https://github.com/scipy/scipy/issues/18308 + disabledTests = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ + "test_a_b_neg_int_after_euler_hypergeometric_transformation" + "test_dst4_definition_ortho" + "test_load_mat4_le" + "hyp2f1_test_case47" + "hyp2f1_test_case3" + "test_uint64_max" + ]; + doCheck = !(stdenv.isx86_64 && stdenv.isDarwin); preConfigure = ''