2020-04-24 23:36:52 +00:00
{ lib
2021-12-06 16:07:01 +00:00
, stdenv
, fetchFromGitHub
2020-04-24 23:36:52 +00:00
, buildPythonPackage
2021-12-06 16:07:01 +00:00
, python
2020-04-24 23:36:52 +00:00
, cython
2022-09-09 14:08:57 +00:00
, pythran
2020-04-24 23:36:52 +00:00
, numpy
, scipy
, matplotlib
, networkx
, six
, pillow
, pywavelets
, dask
, cloudpickle
, imageio
2020-06-15 15:56:04 +00:00
, tifffile
2021-12-06 16:07:01 +00:00
, pytestCheckHook
2020-04-24 23:36:52 +00:00
} :
2021-12-06 16:07:01 +00:00
let
installedPackageRoot = " ${ builtins . placeholder " o u t " } / ${ python . sitePackages } " ;
2022-04-15 01:41:22 +00:00
self = buildPythonPackage rec {
pname = " s c i k i t - i m a g e " ;
2022-09-09 14:08:57 +00:00
version = " 0 . 1 9 . 3 " ;
2020-04-24 23:36:52 +00:00
2022-04-15 01:41:22 +00:00
src = fetchFromGitHub {
owner = pname ;
repo = pname ;
rev = " v ${ version } " ;
2023-03-15 16:39:30 +00:00
hash = " s h a 2 5 6 - z v X g Z d v Y y c F b b M s B F S q M D z L a n E t F 9 + J u V S Q 3 A M 8 / L Q k = " ;
2022-04-15 01:41:22 +00:00
} ;
patches = [ ./add-testing-data.patch ] ;
2020-04-24 23:36:52 +00:00
2022-09-09 14:08:57 +00:00
nativeBuildInputs = [ cython pythran ] ;
2021-12-06 16:07:01 +00:00
2022-04-15 01:41:22 +00:00
propagatedBuildInputs = [
cloudpickle
dask
imageio
matplotlib
networkx
numpy
pillow
pywavelets
scipy
six
tifffile
] ;
2020-04-24 23:36:52 +00:00
2022-04-15 01:41:22 +00:00
# test suite is very cpu intensive, move to passthru.tests
2022-09-09 14:08:57 +00:00
doCheck = false ;
2023-02-02 18:25:31 +00:00
nativeCheckInputs = [ pytestCheckHook ] ;
2020-04-24 23:36:52 +00:00
2022-04-15 01:41:22 +00:00
# (1) The package has cythonized modules, whose .so libs will appear only in the wheel, i.e. in nix store;
# (2) To stop Python from importing the wrong directory, i.e. the one in the build dir, not the one in nix store, `skimage` dir should be removed or renamed;
# (3) Therefore, tests should be run on the installed package in nix store.
2021-12-06 16:07:01 +00:00
2022-04-15 01:41:22 +00:00
# See e.g. https://discourse.nixos.org/t/cant-import-cythonized-modules-at-checkphase/14207 on why the following is needed.
preCheck = ''
rm - r skimage
'' ;
2021-12-06 16:07:01 +00:00
2022-04-15 01:41:22 +00:00
disabledTestPaths = [
# Requires network access (actually some data is loaded via `skimage._shared.testing.fetch` in the global scope, which calls `pytest.skip` when a network is unaccessible, leading to a pytest collection error).
" ${ installedPackageRoot } / s k i m a g e / f i l t e r s / r a n k / t e s t s / t e s t _ r a n k . p y "
] ;
pytestFlagsArray = [ " ${ installedPackageRoot } " " - - p y a r g s " " s k i m a g e " ] ++ builtins . map ( testid : " - - d e s e l e c t = " + testid ) ( [
# These tests require network access
" s k i m a g e / d a t a / t e s t _ d a t a . p y : : t e s t _ s k i n "
" s k i m a g e / d a t a / t e s t s / t e s t _ d a t a . p y : : t e s t _ s k i n "
" s k i m a g e / i o / t e s t s / t e s t _ i o . p y : : t e s t _ i m r e a d _ h t t p _ u r l "
" s k i m a g e / r e s t o r a t i o n / t e s t s / t e s t _ r o l l i n g _ b a l l . p y : : t e s t _ n d i m "
] ++ lib . optionals stdenv . isDarwin [
# Matplotlib tests are broken inside darwin sandbox
" s k i m a g e / f e a t u r e / t e s t s / t e s t _ u t i l . p y : : t e s t _ p l o t _ m a t c h e s "
" s k i m a g e / f i l t e r s / t e s t s / t e s t _ t h r e s h o l d i n g . p y : : T e s t S i m p l e I m a g e : : t e s t _ t r y _ a l l _ t h r e s h o l d "
" s k i m a g e / i o / t e s t s / t e s t _ m p l _ i m s h o w . p y : : "
] ) ;
2020-04-24 23:36:52 +00:00
2022-04-15 01:41:22 +00:00
# Check cythonized modules
pythonImportsCheck = [
" s k i m a g e "
" s k i m a g e . _ s h a r e d "
" s k i m a g e . d r a w "
" s k i m a g e . f e a t u r e "
" s k i m a g e . r e s t o r a t i o n "
" s k i m a g e . f i l t e r s "
" s k i m a g e . f u t u r e . g r a p h "
" s k i m a g e . g r a p h "
" s k i m a g e . i o "
" s k i m a g e . m e a s u r e "
" s k i m a g e . m o r p h o l o g y "
" s k i m a g e . t r a n s f o r m "
" s k i m a g e . u t i l "
" s k i m a g e . s e g m e n t a t i o n "
] ;
2021-12-06 16:07:01 +00:00
2022-04-15 01:41:22 +00:00
passthru . tests = {
all-tests = self . override { doCheck = true ; } ;
} ;
2020-04-24 23:36:52 +00:00
2022-04-15 01:41:22 +00:00
meta = {
description = " I m a g e p r o c e s s i n g r o u t i n e s f o r S c i P y " ;
homepage = " h t t p s : / / s c i k i t - i m a g e . o r g " ;
license = lib . licenses . bsd3 ;
maintainers = with lib . maintainers ; [ yl3dy ] ;
} ;
2020-04-24 23:36:52 +00:00
} ;
2022-04-15 01:41:22 +00:00
in
self