1{ lib
2, stdenv
3, fetchFromGitHub
4, buildPythonPackage
5, python
6, cython
7, numpy
8, scipy
9, matplotlib
10, networkx
11, six
12, pillow
13, pywavelets
14, dask
15, cloudpickle
16, imageio
17, tifffile
18, pytestCheckHook
19}:
20
21let
22 installedPackageRoot = "${builtins.placeholder "out"}/${python.sitePackages}";
23in buildPythonPackage rec {
24 pname = "scikit-image";
25 version = "0.18.3";
26
27 src = fetchFromGitHub {
28 owner = pname;
29 repo = pname;
30 rev = "v${version}";
31 sha256 = "0a2h3bw5rkk23k4r04qc9maccg00nddssd7lfsps8nhp5agk1vyh";
32 };
33
34 patches = [ ./add-testing-data.patch ];
35
36 nativeBuildInputs = [ cython ];
37
38 propagatedBuildInputs = [
39 cloudpickle
40 dask
41 imageio
42 matplotlib
43 networkx
44 numpy
45 pillow
46 pywavelets
47 scipy
48 six
49 tifffile
50 ];
51
52 checkInputs = [ pytestCheckHook ];
53
54 # (1) The package has cythonized modules, whose .so libs will appear only in the wheel, i.e. in nix store;
55 # (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;
56 # (3) Therefore, tests should be run on the installed package in nix store.
57
58 # See e.g. https://discourse.nixos.org/t/cant-import-cythonized-modules-at-checkphase/14207 on why the following is needed.
59 preCheck = ''
60 rm -r skimage
61 '';
62
63 disabledTestPaths = [
64 # 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).
65 "${installedPackageRoot}/skimage/filters/rank/tests/test_rank.py"
66 ];
67 pytestFlagsArray = [ "${installedPackageRoot}" "--pyargs" "skimage" ] ++ builtins.map (testid: "--deselect=" + testid) ([
68 # These tests require network access
69 "skimage/data/test_data.py::test_skin"
70 "skimage/data/tests/test_data.py::test_skin"
71 "skimage/io/tests/test_io.py::test_imread_http_url"
72 "skimage/restoration/tests/test_rolling_ball.py::test_ndim"
73 ] ++ lib.optionals stdenv.isDarwin [
74 # Matplotlib tests are broken inside darwin sandbox
75 "skimage/feature/tests/test_util.py::test_plot_matches"
76 "skimage/filters/tests/test_thresholding.py::TestSimpleImage::test_try_all_threshold"
77 "skimage/io/tests/test_mpl_imshow.py::"
78 ]);
79
80 # Check cythonized modules
81 pythonImportsCheck = [
82 "skimage"
83 "skimage._shared"
84 "skimage.draw"
85 "skimage.feature"
86 "skimage.restoration"
87 "skimage.filters"
88 "skimage.future.graph"
89 "skimage.graph"
90 "skimage.io"
91 "skimage.measure"
92 "skimage.morphology"
93 "skimage.transform"
94 "skimage.util"
95 "skimage.segmentation"
96 ];
97
98 meta = {
99 description = "Image processing routines for SciPy";
100 homepage = "https://scikit-image.org";
101 license = lib.licenses.bsd3;
102 maintainers = with lib.maintainers; [ yl3dy ];
103 };
104}