Skip to content

Commit

Permalink
python3.pkgs.scipy: use pytestCheckHook, remove nose
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 21, 2023
1 parent 8b1886c commit e0d075c
Showing 1 changed file with 8 additions and 39 deletions.
47 changes: 8 additions & 39 deletions pkgs/development/python-modules/scipy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ in buildPythonPackage {
__darwinAllowLocalNetworking = true;

nativeCheckInputs = [
nose
pytestCheckHook
pytest-xdist
];
Expand All @@ -123,6 +122,14 @@ in buildPythonPackage {
"hyp2f1_test_case3"
"test_uint64_max"
];
pytestFlagsArray = [
"-m" "not\\ slow" # fast test suite
];
# Getting import errors without this. A common issue in Nixpkgs, investigated
# at: https://github.com/NixOS/nixpkgs/issues/255262
preCheck = ''
cd $out
'';

doCheck = !(stdenv.isx86_64 && stdenv.isDarwin);

Expand Down Expand Up @@ -158,44 +165,6 @@ 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
'';

requiredSystemFeatures = [ "big-parallel" ]; # the tests need lots of CPU time

passthru = {
Expand Down

0 comments on commit e0d075c

Please sign in to comment.