Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / python-modules / pydicom / default.nix
blobddb4482ef3e7d9c096fcb0940e4cfc2c8675e988
1 { lib
2 , stdenv
3 , buildPythonPackage
4 , fetchFromGitHub
5 , pythonOlder
6 , pytestCheckHook
7 , numpy
8 , pillow
9 , setuptools
12 let
13   pname = "pydicom";
14   version = "2.4.3";
16   src = fetchFromGitHub {
17     owner = "pydicom";
18     repo = "pydicom";
19     rev = "refs/tags/v${version}";
20     hash = "sha256-PF4iA/FPxPYD8OfgWqKRndwi2vURuzh6tlEwduxs/3E=";
21   };
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   };
33 buildPythonPackage {
34   inherit pname version src;
35   disabled = pythonOlder "3.6";
37   format = "setuptools";
39   patches = [
40     # backport of https://github.com/pydicom/pydicom/commit/2513a20cc41743a42bdb86f4cbb4873899b7823c
41     ./pillow-10.1.0-compat.patch
42   ];
44   propagatedBuildInputs = [
45     numpy
46     pillow
47     setuptools
48   ];
50   nativeCheckInputs = [
51     pytestCheckHook
52   ];
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   '';
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   ];
74   pythonImportsCheck = [
75     "pydicom"
76   ];
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   };