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
2023-08-22 20:05:09 +00:00
, pythonOlder
, astropy
, cloudpickle
2020-04-24 23:36:52 +00:00
, cython
2023-08-22 20:05:09 +00:00
, dask
, imageio
, lazy-loader
2020-04-24 23:36:52 +00:00
, matplotlib
2023-08-22 20:05:09 +00:00
, meson-python
2020-04-24 23:36:52 +00:00
, networkx
2023-08-22 20:05:09 +00:00
, numpy
, packaging
2020-04-24 23:36:52 +00:00
, pillow
2023-08-22 20:05:09 +00:00
, pooch
, pyamg
, pytestCheckHook
2024-01-13 08:15:51 +00:00
, numpydoc
2023-08-22 20:05:09 +00:00
, pythran
2020-04-24 23:36:52 +00:00
, pywavelets
2023-08-22 20:05:09 +00:00
, scikit-learn
, scipy
, setuptools
, simpleitk
, six
2020-06-15 15:56:04 +00:00
, tifffile
2023-08-22 20:05:09 +00:00
, wheel
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 " ;
2024-01-13 08:15:51 +00:00
version = " 0 . 2 2 . 0 " ;
2023-08-22 20:05:09 +00:00
format = " p y p r o j e c t " ;
disabled = pythonOlder " 3 . 8 " ;
2020-04-24 23:36:52 +00:00
2022-04-15 01:41:22 +00:00
src = fetchFromGitHub {
2023-08-22 20:05:09 +00:00
owner = " s c i k i t - i m a g e " ;
repo = " s c i k i t - i m a g e " ;
2024-01-13 08:15:51 +00:00
rev = " r e f s / t a g s / v ${ version } " ;
hash = " s h a 2 5 6 - M 1 8 y 5 J B P f 3 D R 7 S l J c C f 8 2 n G 2 M z w I L g 2 w 1 A h J M z Z X s l g = " ;
2022-04-15 01:41:22 +00:00
} ;
2023-08-22 20:05:09 +00:00
postPatch = ''
patchShebangs skimage/_build_utils / { version , cythoner } . py
2023-10-09 19:29:22 +00:00
substituteInPlace pyproject . toml \
- - replace " n u m p y = = " " n u m p y > = "
2023-08-22 20:05:09 +00:00
'' ;
2020-04-24 23:36:52 +00:00
2023-08-22 20:05:09 +00:00
nativeBuildInputs = [
cython
meson-python
numpy
packaging
pythran
setuptools
wheel
] ;
2021-12-06 16:07:01 +00:00
2022-04-15 01:41:22 +00:00
propagatedBuildInputs = [
imageio
2023-08-22 20:05:09 +00:00
lazy-loader
2022-04-15 01:41:22 +00:00
matplotlib
networkx
numpy
2023-08-22 20:05:09 +00:00
packaging
2022-04-15 01:41:22 +00:00
pillow
pywavelets
scipy
tifffile
] ;
2020-04-24 23:36:52 +00:00
2023-08-22 20:05:09 +00:00
passthru . optional-dependencies = {
data = [
pooch
] ;
optional = [
astropy
cloudpickle
dask
matplotlib
pooch
pyamg
scikit-learn
simpleitk
] ++ dask . optional-dependencies . array ;
} ;
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 ;
2024-01-13 08:15:51 +00:00
nativeCheckInputs = [ pytestCheckHook numpydoc ] ;
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 : : "
2024-01-13 08:15:51 +00:00
# See https://github.com/scikit-image/scikit-image/issues/7061 and https://github.com/scikit-image/scikit-image/issues/7104
" s k i m a g e / m e a s u r e / t e s t s / t e s t _ f i t . p y "
2023-08-22 20:05:09 +00:00
] ++ lib . optionals ( stdenv . isDarwin && stdenv . isAarch64 ) [
# https://github.com/scikit-image/scikit-image/issues/7104
" s k i m a g e / m e a s u r e / t e s t s / t e s t _ m o m e n t s . p y "
2022-04-15 01:41:22 +00:00
] ) ;
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 . 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 " ;
2023-08-22 20:05:09 +00:00
changelog = " h t t p s : / / g i t h u b . c o m / s c i k i t - i m a g e / s c i k i t - i m a g e / r e l e a s e s / t a g / ${ src . rev } " ;
2022-04-15 01:41:22 +00:00
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