1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 buildPythonPackage, 6 python, 7 pythonOlder, 8 astropy, 9 cloudpickle, 10 cython, 11 dask, 12 imageio, 13 lazy-loader, 14 matplotlib, 15 meson-python, 16 networkx, 17 numpy, 18 packaging, 19 pillow, 20 pooch, 21 pyamg, 22 pytestCheckHook, 23 numpydoc, 24 pythran, 25 pywavelets, 26 scikit-learn, 27 scipy, 28 setuptools, 29 simpleitk, 30 tifffile, 31 wheel, 32}: 33 34let 35 installedPackageRoot = "${builtins.placeholder "out"}/${python.sitePackages}"; 36 self = buildPythonPackage rec { 37 pname = "scikit-image"; 38 version = "0.25.2"; 39 format = "pyproject"; 40 41 disabled = pythonOlder "3.8"; 42 43 src = fetchFromGitHub { 44 owner = "scikit-image"; 45 repo = "scikit-image"; 46 tag = "v${version}"; 47 hash = "sha256-viRX7Uh9coacueI6gJHBtOay/UIiUQkBfjpmDLJgyZ4="; 48 }; 49 50 postPatch = '' 51 patchShebangs skimage/_build_utils/{version,cythoner}.py 52 ''; 53 54 nativeBuildInputs = [ 55 cython 56 meson-python 57 numpy 58 packaging 59 pythran 60 setuptools 61 wheel 62 ]; 63 64 propagatedBuildInputs = [ 65 imageio 66 lazy-loader 67 matplotlib 68 networkx 69 numpy 70 packaging 71 pillow 72 pywavelets 73 scipy 74 tifffile 75 ]; 76 77 optional-dependencies = { 78 data = [ pooch ]; 79 optional = [ 80 astropy 81 cloudpickle 82 dask 83 matplotlib 84 pooch 85 pyamg 86 scikit-learn 87 simpleitk 88 ] ++ dask.optional-dependencies.array; 89 }; 90 91 # test suite is very cpu intensive, move to passthru.tests 92 doCheck = false; 93 nativeCheckInputs = [ 94 pytestCheckHook 95 numpydoc 96 ]; 97 98 # (1) The package has cythonized modules, whose .so libs will appear only in the wheel, i.e. in nix store; 99 # (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; 100 # (3) Therefore, tests should be run on the installed package in nix store. 101 102 # See e.g. https://discourse.nixos.org/t/cant-import-cythonized-modules-at-checkphase/14207 on why the following is needed. 103 preCheck = '' 104 rm -r skimage 105 ''; 106 107 disabledTestPaths = [ 108 # 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). 109 "${installedPackageRoot}/skimage/filters/rank/tests/test_rank.py" 110 ]; 111 pytestFlagsArray = 112 [ 113 "${installedPackageRoot}" 114 "--pyargs" 115 "skimage" 116 ] 117 ++ builtins.map (testid: "--deselect=" + testid) ( 118 [ 119 # These tests require network access 120 "skimage/data/test_data.py::test_skin" 121 "skimage/data/tests/test_data.py::test_skin" 122 "skimage/io/tests/test_io.py::test_imread_http_url" 123 "skimage/restoration/tests/test_rolling_ball.py::test_ndim" 124 ] 125 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 126 # Matplotlib tests are broken inside darwin sandbox 127 "skimage/feature/tests/test_util.py::test_plot_matches" 128 "skimage/filters/tests/test_thresholding.py::TestSimpleImage::test_try_all_threshold" 129 "skimage/io/tests/test_mpl_imshow.py::" 130 # See https://github.com/scikit-image/scikit-image/issues/7061 and https://github.com/scikit-image/scikit-image/issues/7104 131 "skimage/measure/tests/test_fit.py" 132 ] 133 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 134 # https://github.com/scikit-image/scikit-image/issues/7104 135 "skimage/measure/tests/test_moments.py" 136 ] 137 ); 138 139 # Check cythonized modules 140 pythonImportsCheck = [ 141 "skimage" 142 "skimage._shared" 143 "skimage.draw" 144 "skimage.feature" 145 "skimage.restoration" 146 "skimage.filters" 147 "skimage.graph" 148 "skimage.io" 149 "skimage.measure" 150 "skimage.morphology" 151 "skimage.transform" 152 "skimage.util" 153 "skimage.segmentation" 154 ]; 155 156 passthru.tests = { 157 all-tests = self.overridePythonAttrs { doCheck = true; }; 158 }; 159 160 meta = { 161 description = "Image processing routines for SciPy"; 162 homepage = "https://scikit-image.org"; 163 changelog = "https://github.com/scikit-image/scikit-image/releases/tag/${src.tag}"; 164 license = lib.licenses.bsd3; 165 maintainers = with lib.maintainers; [ yl3dy ]; 166 }; 167 }; 168in 169self