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