gnu: python-scikit-image: Fix tests.

In some cases there could be an issue to test compiled Cython library
which is not available in local checkout working directory.  This change
is inspired by the way NixOS packages scikit-image and run tests from
the output with "--pyargs" option where compiled library is available.

See: <https://github.com/NixOS/nixpkgs/blob/nixos-25.05/\
pkgs/development/python-modules/scikit-image/default.nix>.

* gnu/packages/python-science.scm (python-scikit-image) [arguments]
<test-flags>: Run tests from {#$output}, add "--pyargs" option and skip
one more problematic test.
<phases>: Use default 'check; add 'pre-check and post-check.

Change-Id: I60f58359f59b371854f4963e2f7c65c9221a0924
This commit is contained in:
Sharlatan Hellseher 2025-06-29 21:20:40 +01:00
parent d7c5315913
commit 0fb7ae747f
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -2256,28 +2256,41 @@ logic, also known as grey logic.")
(origin (origin
(method git-fetch) (method git-fetch)
(uri (git-reference (uri (git-reference
(url "https://github.com/scikit-image/scikit-image") (url "https://github.com/scikit-image/scikit-image")
(commit (string-append "v" version)))) (commit (string-append "v" version))))
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 "1bc8i57sjk44vd9k1ilr6fpvfq1zbq9yfi22lz22k26mzrlisym3")))) (base32 "1bc8i57sjk44vd9k1ilr6fpvfq1zbq9yfi22lz22k26mzrlisym3"))))
(build-system pyproject-build-system) (build-system pyproject-build-system)
(arguments (arguments
(list (list
;; Disable flaky test #:test-flags
#:test-flags #~(list "-k" "not test_ellipse_parameter_stability") ;; To make sure we test compiled and installed module.
#~(list (string-append #$output "/lib/python"
#$(version-major+minor (package-version python))
"/site-packages")
"--pyargs" "skimage"
;; Disable flaky test
"-k" (string-join
(list "not test_ellipse_parameter_stability"
;; ValueError: Cannot call len() on object with unknown chunk size.
"test_thresholds_dask_compatibility[threshold_triangle-41-43]")
" and not "))
#:phases #:phases
#~(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-before 'build 'change-home-dir (add-before 'build 'change-home-dir
(lambda _ (lambda _
;; Change from /homeless-shelter to /tmp for write permission. ;; Change from /homeless-shelter to /tmp for write permission.
(setenv "HOME" "/tmp"))) (setenv "HOME" "/tmp")))
(replace 'check (add-before 'check 'pre-check
(lambda* (#:key tests? test-flags #:allow-other-keys) (lambda _
(when tests? ;; To prevent loading tests twise.
(with-directory-excursion "/tmp" ;; 16277 passed, 240 skipped, 4 deselected
(apply invoke "pytest" "-v" "--doctest-modules" (delete-file-recursively "skimage")))
(append test-flags (list #$output)))))))))) (add-before 'check 'post-check
(lambda _
(for-each delete-file-recursively
(find-files #$output "__pycache__" #:directories? #t)))))))
;; See requirements/ for the list of build and run time requirements. ;; See requirements/ for the list of build and run time requirements.
;; NOTE: scikit-image has an optional dependency on python-pooch, however ;; NOTE: scikit-image has an optional dependency on python-pooch, however
;; propagating it would enable many more tests that require online data. ;; propagating it would enable many more tests that require online data.