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 ] 89 ++ dask.optional-dependencies.array; 90 }; 91 92 # test suite is very cpu intensive, move to passthru.tests 93 doCheck = false; 94 nativeCheckInputs = [ 95 pytestCheckHook 96 numpydoc 97 ]; 98 99 # (1) The package has cythonized modules, whose .so libs will appear only in the wheel, i.e. in nix store; 100 # (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; 101 # (3) Therefore, tests should be run on the installed package in nix store. 102 103 # See e.g. https://discourse.nixos.org/t/cant-import-cythonized-modules-at-checkphase/14207 on why the following is needed. 104 preCheck = '' 105 rm -r skimage 106 ''; 107 108 pytestFlagsArray = [ 109 "${installedPackageRoot}" 110 "--pyargs" 111 "skimage" 112 ]; 113 114 disabledTestPaths = [ 115 # 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). 116 "${installedPackageRoot}/skimage/filters/rank/tests/test_rank.py" 117 118 # These tests require network access 119 "skimage/data/test_data.py::test_skin" 120 "skimage/data/tests/test_data.py::test_skin" 121 "skimage/io/tests/test_io.py::test_imread_http_url" 122 "skimage/restoration/tests/test_rolling_ball.py::test_ndim" 123 ] 124 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 125 # Matplotlib tests are broken inside darwin sandbox 126 "skimage/feature/tests/test_util.py::test_plot_matches" 127 "skimage/filters/tests/test_thresholding.py::TestSimpleImage::test_try_all_threshold" 128 "skimage/io/tests/test_mpl_imshow.py::" 129 # See https://github.com/scikit-image/scikit-image/issues/7061 and https://github.com/scikit-image/scikit-image/issues/7104 130 "skimage/measure/tests/test_fit.py" 131 ] 132 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 133 # https://github.com/scikit-image/scikit-image/issues/7104 134 "skimage/measure/tests/test_moments.py" 135 ]; 136 137 # Check cythonized modules 138 pythonImportsCheck = [ 139 "skimage" 140 "skimage._shared" 141 "skimage.draw" 142 "skimage.feature" 143 "skimage.restoration" 144 "skimage.filters" 145 "skimage.graph" 146 "skimage.io" 147 "skimage.measure" 148 "skimage.morphology" 149 "skimage.transform" 150 "skimage.util" 151 "skimage.segmentation" 152 ]; 153 154 passthru.tests = { 155 all-tests = self.overridePythonAttrs { doCheck = true; }; 156 }; 157 158 meta = { 159 description = "Image processing routines for SciPy"; 160 homepage = "https://scikit-image.org"; 161 changelog = "https://github.com/scikit-image/scikit-image/releases/tag/${src.tag}"; 162 license = lib.licenses.bsd3; 163 maintainers = with lib.maintainers; [ yl3dy ]; 164 }; 165 }; 166in 167self