1{ buildPythonPackage
2, fetchFromGitHub
3, fetchpatch
4, pillow
5, scipy
6, numpy
7, pytestCheckHook
8, imread
9, freeimage
10, lib
11, stdenv
12}:
13
14buildPythonPackage rec {
15 pname = "mahotas";
16 version = "1.4.13";
17
18 src = fetchFromGitHub {
19 owner = "luispedro";
20 repo = "mahotas";
21 rev = "v${version}";
22 hash = "sha256-AmctF/9hLgHw6FUm0s61eCdcc12lBa1t0OkXclis//w=";
23 };
24
25 propagatedBuildInputs = [
26 freeimage
27 imread
28 numpy
29 pillow
30 scipy
31 ];
32
33 nativeCheckInputs = [ pytestCheckHook ];
34
35 postPatch = ''
36 substituteInPlace mahotas/io/freeimage.py \
37 --replace "ctypes.util.find_library('freeimage')" 'True' \
38 --replace 'ctypes.CDLL(libname)' 'np.ctypeslib.load_library("libfreeimage", "${freeimage}/lib")'
39 '';
40
41 # mahotas/_morph.cpp:864:10: error: no member named 'random_shuffle' in namespace 'std'
42 env = lib.optionalAttrs stdenv.cc.isClang {
43 NIX_CFLAGS_COMPILE = "-std=c++14";
44 };
45
46 # tests must be run in the build directory
47 preCheck = ''
48 cd build/lib*
49 '';
50
51 # re-enable as soon as https://github.com/luispedro/mahotas/issues/97 is fixed
52 disabledTests = [
53 "test_colors"
54 "test_ellipse_axes"
55 "test_normalize"
56 "test_haralick3d"
57 ];
58
59 pythonImportsCheck = [
60 "mahotas"
61 "mahotas.freeimage"
62 ];
63
64 disabled = stdenv.isi686; # Failing tests
65
66 meta = with lib; {
67 broken = (stdenv.isLinux && stdenv.isAarch64);
68 description = "Computer vision package based on numpy";
69 homepage = "https://mahotas.readthedocs.io/";
70 maintainers = with maintainers; [ luispedro ];
71 license = licenses.mit;
72 platforms = platforms.unix;
73 };
74}