From 72b193e7c11684e0f0d09f88efcc268b6661f874 Mon Sep 17 00:00:00 2001 From: Alexander Kiselyov Date: Fri, 12 Nov 2021 19:17:20 +0300 Subject: [PATCH] python3Packages.scikitimage: 0.18.1 -> 0.18.3 (#137038) --- .../scikit-image/add-testing-data.patch | 17 +++++ .../python-modules/scikit-image/default.nix | 62 ++++++++++++++++--- 2 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 pkgs/development/python-modules/scikit-image/add-testing-data.patch diff --git a/pkgs/development/python-modules/scikit-image/add-testing-data.patch b/pkgs/development/python-modules/scikit-image/add-testing-data.patch new file mode 100644 index 000000000000..60f9287f8b1c --- /dev/null +++ b/pkgs/development/python-modules/scikit-image/add-testing-data.patch @@ -0,0 +1,17 @@ +diff --git a/skimage/data/setup.py b/skimage/data/setup.py +index 528e9c284ce..ba0e155559c 100644 +--- a/skimage/data/setup.py ++++ b/skimage/data/setup.py +@@ -11,7 +11,11 @@ def configuration(parent_package='', top_path=None): + # further notice. + # Testing data and additional datasets should only + # be made available via pooch +- config.add_data_files(*legacy_datasets) ++ # Nix patch: add ALL images to facilitate testing of a fully-built package ++ from pathlib import Path ++ config.add_data_files( ++ *(path.name for path in Path(__file__).parent.glob("*") if path.suffix != ".py") ++ ) + # It seems hard to create a consistent hash for README.txt since + # the line endings keep getting converted + config.add_data_files('README.txt') diff --git a/pkgs/development/python-modules/scikit-image/default.nix b/pkgs/development/python-modules/scikit-image/default.nix index b34d3ff7b8de..9c3583fe365a 100644 --- a/pkgs/development/python-modules/scikit-image/default.nix +++ b/pkgs/development/python-modules/scikit-image/default.nix @@ -1,6 +1,7 @@ { lib -, fetchPypi +, fetchFromGitHub , buildPythonPackage +, python , cython , numpy , scipy @@ -11,20 +12,26 @@ , pywavelets , dask , cloudpickle -, pytest , imageio , tifffile +, pytestCheckHook }: -buildPythonPackage rec { +let + installedPackageRoot = "${builtins.placeholder "out"}/${python.sitePackages}"; +in buildPythonPackage rec { pname = "scikit-image"; version = "0.18.3"; - src = fetchPypi { - inherit pname version; - sha256 = "ecae99f93f4c5e9b1bf34959f4dc596c41f2f6b2fc407d9d9ddf85aebd3137ca"; + src = fetchFromGitHub { + owner = pname; + repo = pname; + rev = "v${version}"; + sha256 = "0a2h3bw5rkk23k4r04qc9maccg00nddssd7lfsps8nhp5agk1vyh"; }; + patches = [ ./add-testing-data.patch ]; + nativeBuildInputs = [ cython ]; propagatedBuildInputs = [ @@ -41,14 +48,51 @@ buildPythonPackage rec { tifffile ]; - checkInputs = [ pytest ]; + checkInputs = [ pytestCheckHook ]; - # No tests in archive - doCheck = false; + # (1) The package has cythonized modules, whose .so libs will appear only in the wheel, i.e. in nix store; + # (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; + # (3) Therefore, tests should be run on the installed package in nix store. + + # See e.g. https://discourse.nixos.org/t/cant-import-cythonized-modules-at-checkphase/14207 on why the following is needed. + preCheck = '' + rm -r skimage + ''; + + disabledTestPaths = [ + # 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). + "${installedPackageRoot}/skimage/filters/rank/tests/test_rank.py" + ]; + pytestFlagsArray = [ "${installedPackageRoot}" "--pyargs" "skimage" ] ++ builtins.map (testid: "--deselect=" + testid) [ + # These tests require network access + "skimage/data/test_data.py::test_skin" + "skimage/data/tests/test_data.py::test_skin" + "skimage/io/tests/test_io.py::test_imread_http_url" + "skimage/restoration/tests/test_rolling_ball.py::test_ndim" + ]; + + # Check cythonized modules + pythonImportsCheck = [ + "skimage" + "skimage._shared" + "skimage.draw" + "skimage.feature" + "skimage.restoration" + "skimage.filters" + "skimage.future.graph" + "skimage.graph" + "skimage.io" + "skimage.measure" + "skimage.morphology" + "skimage.transform" + "skimage.util" + "skimage.segmentation" + ]; meta = { description = "Image processing routines for SciPy"; homepage = "https://scikit-image.org"; license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ yl3dy ]; }; }