1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 substituteAll,
6 glibc,
7 libtiff,
8 openjpeg,
9 fetchFromGitHub,
10 lxml,
11 numpy,
12 pytestCheckHook,
13 pythonOlder,
14 scikit-image,
15 setuptools,
16}:
17
18buildPythonPackage rec {
19 pname = "glymur";
20 version = "0.13.4";
21 pyproject = true;
22
23 disabled = pythonOlder "3.6";
24
25 src = fetchFromGitHub {
26 owner = "quintusdias";
27 repo = "glymur";
28 rev = "refs/tags/v${version}";
29 hash = "sha256-RzRZuSNvlUrB+J93a1ob7dDMacZB082JwVHQ9Fce2JA=";
30 };
31
32 patches = [
33 (substituteAll {
34 src = ./set-lib-paths.patch;
35 openjp2_lib = "${lib.getLib openjpeg}/lib/libopenjp2${stdenv.hostPlatform.extensions.sharedLibrary}";
36 tiff_lib = "${lib.getLib libtiff}/lib/libtiff${stdenv.hostPlatform.extensions.sharedLibrary}";
37 })
38 ];
39
40 postPatch = lib.optionalString (!stdenv.isDarwin) ''
41 substituteInPlace glymur/lib/tiff.py \
42 --replace-fail "glymur_config('c')" "ctypes.CDLL('${lib.getLib glibc}/lib/libc.so.6')"
43 '';
44
45 __propagatedImpureHostDeps = lib.optional stdenv.isDarwin "/usr/lib/libc.dylib";
46
47 build-system = [ setuptools ];
48
49 dependencies = [
50 lxml
51 numpy
52 ];
53
54 nativeCheckInputs = [
55 pytestCheckHook
56 scikit-image
57 ];
58
59 preCheck = ''
60 export PATH="$out/bin:$PATH"
61 '';
62
63 disabledTestPaths = [
64 # this test involves glymur's different ways of finding the openjpeg path on
65 # fsh systems by reading an .rc file and such, and is obviated by the patch
66 "tests/test_config.py"
67 ];
68
69 pythonImportsCheck = [ "glymur" ];
70
71 meta = {
72 description = "Tools for accessing JPEG2000 files";
73 homepage = "https://github.com/quintusdias/glymur";
74 changelog = "https://github.com/quintusdias/glymur/blob/${src.rev}/CHANGES.txt";
75 license = lib.licenses.mit;
76 maintainers = with lib.maintainers; [ tomasajt ];
77 };
78}