1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, pythonOlder
6, pytestCheckHook
7, numpy
8, pillow
9, setuptools
10}:
11
12let
13 pname = "pydicom";
14 version = "2.4.3";
15
16 src = fetchFromGitHub {
17 owner = "pydicom";
18 repo = "pydicom";
19 rev = "refs/tags/v${version}";
20 hash = "sha256-PF4iA/FPxPYD8OfgWqKRndwi2vURuzh6tlEwduxs/3E=";
21 };
22
23 # Pydicom needs pydicom-data to run some tests. If these files aren't downloaded
24 # before the package creation, it'll try to download during the checkPhase.
25 test_data = fetchFromGitHub {
26 owner = "pydicom";
27 repo = "pydicom-data";
28 rev = "cbb9b2148bccf0f550e3758c07aca3d0e328e768";
29 hash = "sha256-nF/j7pfcEpWHjjsqqTtIkW8hCEbuQ3J4IxpRk0qc1CQ=";
30 };
31
32in
33buildPythonPackage {
34 inherit pname version src;
35 disabled = pythonOlder "3.6";
36
37 format = "setuptools";
38
39 patches = [
40 # backport of https://github.com/pydicom/pydicom/commit/2513a20cc41743a42bdb86f4cbb4873899b7823c
41 ./pillow-10.1.0-compat.patch
42 ];
43
44 propagatedBuildInputs = [
45 numpy
46 pillow
47 setuptools
48 ];
49
50 nativeCheckInputs = [
51 pytestCheckHook
52 ];
53
54 # Setting $HOME to prevent pytest to try to create a folder inside
55 # /homeless-shelter which is read-only.
56 # Linking pydicom-data dicom files to $HOME/.pydicom/data
57 preCheck = ''
58 export HOME=$TMP/test-home
59 mkdir -p $HOME/.pydicom/
60 ln -s ${test_data}/data_store/data $HOME/.pydicom/data
61 '';
62
63 disabledTests = [
64 # tries to remove a dicom inside $HOME/.pydicom/data/ and download it again
65 "test_fetch_data_files"
66 ] ++ lib.optionals stdenv.isAarch64 [
67 # https://github.com/pydicom/pydicom/issues/1386
68 "test_array"
69 ] ++ lib.optionals stdenv.isDarwin [
70 # flaky, hard to reproduce failure outside hydra
71 "test_time_check"
72 ];
73
74 pythonImportsCheck = [
75 "pydicom"
76 ];
77
78 meta = with lib; {
79 description = "Python package for working with DICOM files";
80 homepage = "https://pydicom.github.io";
81 license = licenses.mit;
82 maintainers = with maintainers; [ bcdarwin ];
83 };
84}