1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, isPy27
6, pytest-runner
7, pytestCheckHook
8, numpy
9, pillow
10}:
11
12let
13 pname = "pydicom";
14 version = "2.1.2";
15
16 src = fetchFromGitHub {
17 owner = "${pname}";
18 repo = "${pname}";
19 rev = "v${version}";
20 sha256 = "sha256-iExy+mUs1uqs/u9N6btlqyP6/TvoPVsuOuzs56zZAS8=";
21 };
22
23 # Pydicom needs pydicom-data to run some tests. If these files are downloaded
24 # before the package creation, it'll try to download during the checkPhase.
25 test_data = fetchFromGitHub {
26 owner = "${pname}";
27 repo = "${pname}-data";
28 rev = "bbb723879690bb77e077a6d57657930998e92bd5";
29 sha256 = "sha256-dCI1temvpNWiWJYVfQZKy/YJ4ad5B0e9hEKHJnEeqzk=";
30 };
31
32in
33buildPythonPackage {
34 inherit pname version src;
35 disabled = isPy27;
36
37 propagatedBuildInputs = [ numpy pillow ];
38
39 checkInputs = [ pytest-runner pytestCheckHook ];
40
41 # Setting $HOME to prevent pytest to try to create a folder inside
42 # /homeless-shelter which is read-only.
43 # Linking pydicom-data dicom files to $HOME/.pydicom/data
44 preCheck = ''
45 export HOME=$TMP/test-home
46 mkdir -p $HOME/.pydicom/
47 ln -s ${test_data}/data_store/data $HOME/.pydicom/data
48 '';
49
50 # This test try to remove a dicom inside $HOME/.pydicom/data/ and download it again.
51 disabledTests = [
52 "test_fetch_data_files"
53 ] ++ lib.optionals stdenv.isAarch64 [
54 # https://github.com/pydicom/pydicom/issues/1386
55 "test_array"
56 ] ++ lib.optionals stdenv.isDarwin [
57 # flaky, hard to reproduce failure outside hydra
58 "test_time_check"
59 ];
60
61 meta = with lib; {
62 homepage = "https://pydicom.github.io";
63 description = "Pure-Python package for working with DICOM files";
64 license = licenses.mit;
65 maintainers = with maintainers; [ bcdarwin ];
66 };
67}