From 2a67612019f5be184889ab2466fb7e7b68461e7c Mon Sep 17 00:00:00 2001 From: Luis Pedro Coelho Date: Tue, 5 Mar 2024 11:57:44 +1000 Subject: [PATCH] python311Packages.imread: Fix testing Use pytestCheckHook to fix tests As per suggestions on PR from @dotlambda, switched to `pyproject=true` and `hash` and reformatted the package. closes #293191 --- .../python-modules/imread/default.nix | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/imread/default.nix b/pkgs/development/python-modules/imread/default.nix index 4e3b4294991c..69eb79ddbcaa 100644 --- a/pkgs/development/python-modules/imread/default.nix +++ b/pkgs/development/python-modules/imread/default.nix @@ -1,8 +1,9 @@ { lib , buildPythonPackage , fetchPypi -, nose +, pytestCheckHook , pkg-config +, setuptools , libjpeg , libpng , libtiff @@ -13,18 +14,48 @@ buildPythonPackage rec { pname = "python-imread"; version = "0.7.5"; + pyproject = true; src = fetchPypi { inherit version; pname = "imread"; - sha256 = "sha256-GiWpA128GuLlbBW1CQQHHVVeoZfu9Yyh2RFzSdtHDbc="; + hash = "sha256-GiWpA128GuLlbBW1CQQHHVVeoZfu9Yyh2RFzSdtHDbc="; }; + nativeBuildInputs = [ + pkg-config + setuptools + ]; + + buildInputs = [ + libjpeg + libpng + libtiff + libwebp + ]; - nativeBuildInputs = [ pkg-config ]; - buildInputs = [ nose libjpeg libpng libtiff libwebp ]; propagatedBuildInputs = [ numpy ]; + nativeCheckInputs = [ + pytestCheckHook + ]; + + pytestFlagsArray = [ + # verbose build outputs needed to debug hard-to-reproduce hydra failures + "-v" + "--pyargs" "imread" + ]; + + pythonImportsCheck = [ + "imread" + ]; + + preCheck = '' + cd $TMPDIR + export HOME=$TMPDIR + export OMP_NUM_THREADS=1 + ''; + meta = with lib; { description = "Python package to load images as numpy arrays"; homepage = "https://imread.readthedocs.io/en/latest/";