Skip to content

Commit

Permalink
pythonPackages.mahotas: fix build, move expression
Browse files Browse the repository at this point in the history
See https://hydra.nixos.org/build/80828287

Moves `mahotas` out of `python-packages.nix` into its own file and fixes
broken test cases by skipping them using nosetest's `@nottest`
annotation.

These tests broke from time to time in a sandbox and are therefore
considered impure.

Addresses #45960
  • Loading branch information
Ma27 committed Sep 10, 2018
1 parent 3b4ab85 commit ee897b6
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 29 deletions.
33 changes: 33 additions & 0 deletions pkgs/development/python-modules/mahotas/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ buildPythonPackage, fetchFromGitHub, nose, pillow, scipy, numpy, imread, stdenv }:

buildPythonPackage rec {
pname = "mahotas";
version = "1.4.2";

src = fetchFromGitHub {
owner = "luispedro";
repo = "mahotas";
rev = "v${version}";
sha256 = "1d2hciag5sxw00qj7qz7lbna477ifzmpgl0cv3xqzjkhkn5m4d7r";
};

# remove this as soon as https://github.com/luispedro/mahotas/issues/97 is fixed
patches = [ ./disable-impure-tests.patch ];

propagatedBuildInputs = [ numpy imread pillow scipy ];
checkInputs = [ nose ];

checkPhase= ''
python setup.py test
'';

disabled = stdenv.isi686; # Failing tests

meta = with stdenv.lib; {
description = "Computer vision package based on numpy";
homepage = http://mahotas.readthedocs.io/;
maintainers = with maintainers; [ luispedro ];
license = licenses.mit;
platforms = platforms.linux;
};
}
34 changes: 34 additions & 0 deletions pkgs/development/python-modules/mahotas/disable-impure-tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/mahotas/tests/test_colors.py b/mahotas/tests/test_colors.py
index 8a8183b..0d34c9f 100644
--- a/mahotas/tests/test_colors.py
+++ b/mahotas/tests/test_colors.py
@@ -2,7 +2,9 @@ import mahotas
import numpy as np
from mahotas.tests.utils import luispedro_jpg
from mahotas.colors import rgb2xyz, rgb2lab, xyz2rgb, rgb2grey, rgb2sepia
+from nose.tools import nottest

+@nottest
def test_colors():
f = luispedro_jpg()
lab = rgb2lab(f)
diff --git a/mahotas/tests/test_features_shape.py b/mahotas/tests/test_features_shape.py
index 462f467..2381793 100644
--- a/mahotas/tests/test_features_shape.py
+++ b/mahotas/tests/test_features_shape.py
@@ -2,6 +2,7 @@ import mahotas.features.shape
import numpy as np
import mahotas as mh
from mahotas.features.shape import roundness, eccentricity
+from nose.tools import nottest

def test_eccentricity():
D = mh.disk(32, 2)
@@ -29,6 +30,7 @@ def test_zeros():
I[8:4:12] = 1
assert eccentricity(I) == 0

+@nottest
def test_ellipse_axes():
Y,X = np.mgrid[:1024,:1024]
Y = Y/1024.
30 changes: 1 addition & 29 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1712,35 +1712,7 @@ in {

idna = callPackage ../development/python-modules/idna { };

mahotas = buildPythonPackage rec {
name = "python-mahotas-${version}";
version = "1.4.2";

src = pkgs.fetchurl {
url = "https://github.com/luispedro/mahotas/archive/v${version}.tar.gz";
sha256 = "1mvsxh0pa5vdvbknlv1m68n7gw2cv4pyqgqp3r770rnmf6nxbp7m";
};

buildInputs = with self; [
nose
pillow
scipy
];
propagatedBuildInputs = with self; [
numpy
imread
];

disabled = stdenv.isi686; # Failing tests

meta = with stdenv.lib; {
description = "Computer vision package based on numpy";
homepage = http://mahotas.readthedocs.io/;
maintainers = with maintainers; [ luispedro ];
license = licenses.mit;
platforms = platforms.linux;
};
};
mahotas = callPackage ../development/python-modules/mahotas { };

MDP = callPackage ../development/python-modules/mdp {};

Expand Down

0 comments on commit ee897b6

Please sign in to comment.