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