1{
2 stdenv,
3 lib,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 cmake,
8 cython,
9 poetry-core,
10 setuptools,
11 numpy,
12 openjpeg,
13 pytestCheckHook,
14 pydicom,
15 pylibjpeg,
16 pylibjpeg-data,
17}:
18
19buildPythonPackage rec {
20 pname = "pylibjpeg-openjpeg";
21 version = "2.5.0";
22 pyproject = true;
23
24 disabled = pythonOlder "3.8";
25
26 src = fetchFromGitHub {
27 owner = "pydicom";
28 repo = "pylibjpeg-openjpeg";
29 tag = "v${version}";
30 hash = "sha256-siZ/Mm1wmd7dWhGa4rdH9Frxis2jB9av/Kw2dEe5dpI=";
31 };
32
33 # don't use vendored openjpeg submodule:
34 # (note build writes into openjpeg source dir, so we have to make it writable)
35 postPatch = ''
36 rmdir lib/openjpeg
37 cp -r ${openjpeg.src} lib/openjpeg
38 chmod +rwX -R lib/openjpeg
39
40 substituteInPlace pyproject.toml --replace-fail "poetry-core >=1.8,<2" "poetry-core"
41 '';
42
43 dontUseCmakeConfigure = true;
44
45 build-system = [
46 cmake
47 cython
48 poetry-core
49 setuptools
50 ];
51
52 dependencies = [ numpy ];
53
54 nativeCheckInputs = [
55 pytestCheckHook
56 pydicom
57 pylibjpeg-data
58 pylibjpeg
59 ];
60 disabledTestPaths = [
61 # ignore a few Python test files (e.g. performance tests) in openjpeg itself:
62 "lib/openjpeg"
63 ];
64
65 enabledTestPaths = [ "openjpeg/tests" ];
66
67 pythonImportsCheck = [ "openjpeg" ];
68
69 meta = {
70 description = "J2K and JP2 plugin for pylibjpeg";
71 homepage = "https://github.com/pydicom/pylibjpeg-openjpeg";
72 changelog = "https://github.com/pydicom/pylibjpeg-openjpeg/releases/tag/${src.tag}";
73 license = [ lib.licenses.mit ];
74 maintainers = with lib.maintainers; [ bcdarwin ];
75 # darwin: numerous test failures, test dependency pydicom is marked as unsupported
76 broken = stdenv.hostPlatform.isDarwin;
77 };
78}