Skip to content

Commit

Permalink
python3.pkgs.scipy: use pytestCheckHook
Browse files Browse the repository at this point in the history
Related to: NixOS#255262 . This allows
Using the hook's builtin support for of `disabledTests` and
`disabledTestPaths`.
  • Loading branch information
doronbehar committed Sep 20, 2023
1 parent 8b1886c commit 7230254
Showing 1 changed file with 7 additions and 36 deletions.
43 changes: 7 additions & 36 deletions pkgs/development/python-modules/scipy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7230254

Please sign in to comment.