From 7230254aa5a706ac6fabec8103adbe7b71a945d2 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 17 Sep 2023 10:42:53 +0300 Subject: [PATCH] python3.pkgs.scipy: use pytestCheckHook Related to: https://github.com/NixOS/nixpkgs/issues/255262 . This allows Using the hook's builtin support for of `disabledTests` and `disabledTestPaths`. --- .../python-modules/scipy/default.nix | 43 +++---------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/pkgs/development/python-modules/scipy/default.nix b/pkgs/development/python-modules/scipy/default.nix index 7312e53ed41371a..914ba42976ec13a 100644 --- a/pkgs/development/python-modules/scipy/default.nix +++ b/pkgs/development/python-modules/scipy/default.nix @@ -123,6 +123,9 @@ in buildPythonPackage { "hyp2f1_test_case3" "test_uint64_max" ]; + pytestFlagsArray = [ + "-m" "not\\ slow" # fast test suite + ]; doCheck = !(stdenv.isx86_64 && stdenv.isDarwin); @@ -158,42 +161,10 @@ in buildPythonPackage { # hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ]; - 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, - extra_argv=[$args], - parallel=$NIX_BUILD_CORES - ) != True)" - popd - runHook postCheck + # Getting import errors without this. A common issue in Nixpkgs, investigated + # at: https://github.com/NixOS/nixpkgs/issues/255262 + preCheck = '' + cd $out ''; requiredSystemFeatures = [ "big-parallel" ]; # the tests need lots of CPU time