about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pylibjpeg-openjpeg/default.nix
blob: 33f1b807ac50f92ea6dabf026b29746129277a06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
  stdenv,
  lib,
  buildPythonPackage,
  pythonOlder,
  fetchFromGitHub,
  cmake,
  cython,
  poetry-core,
  setuptools,
  numpy,
  openjpeg,
  pytestCheckHook,
  pydicom,
  pylibjpeg,
  pylibjpeg-data,
}:

buildPythonPackage rec {
  pname = "pylibjpeg-openjpeg";
  version = "2.3.0";
  pyproject = true;

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "pydicom";
    repo = "pylibjpeg-openjpeg";
    rev = "refs/tags/v${version}";
    hash = "sha256-cCDnARElNn+uY+HQ39OnGJRz2vTz0I8s0Oe+qGvqM1o=";
  };

  # don't use vendored openjpeg submodule:
  # (note build writes into openjpeg source dir, so we have to make it writable)
  postPatch = ''
    rmdir lib/openjpeg
    cp -r ${openjpeg.src} lib/openjpeg
    chmod +rwX -R lib/openjpeg
  '';

  dontUseCmakeConfigure = true;

  build-system = [
    cmake
    cython
    poetry-core
    setuptools
  ];

  dependencies = [ numpy ];

  nativeCheckInputs = [
    pytestCheckHook
    pydicom
    pylibjpeg-data
    pylibjpeg
  ];
  disabledTestPaths = [
    # ignore a few Python test files (e.g. performance tests) in openjpeg itself:
    "lib/openjpeg"
  ];

  pytestFlagsArray = [ "openjpeg/tests" ];

  pythonImportsCheck = [ "openjpeg" ];

  meta = {
    description = "A J2K and JP2 plugin for pylibjpeg";
    homepage = "https://github.com/pydicom/pylibjpeg-openjpeg";
    license = [ lib.licenses.mit ];
    maintainers = with lib.maintainers; [ bcdarwin ];
    # x86-linux: test_encode.py::TestEncodeBuffer failures
    # darwin: numerous test failures, seemingly due to issues setting up test data
    broken = (stdenv.isAarch64 && stdenv.isLinux) || stdenv.isDarwin;
  };
}