nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 112 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 flit-core, 7 numpy, 8 pytestCheckHook, 9 10 # optional/test dependencies 11 gdcm, 12 pillow, 13 pydicom, 14 pyjpegls, 15 pylibjpeg, 16 pylibjpeg-libjpeg, 17 writableTmpDirAsHomeHook, 18}: 19let 20 # Pydicom needs pydicom-data to run some tests. If these files aren't downloaded 21 # before the package creation, it'll try to download during the checkPhase. 22 test_data = fetchFromGitHub { 23 owner = "pydicom"; 24 repo = "pydicom-data"; 25 rev = "8da482f208401d63cd63f3f4efc41b6856ef36c7"; 26 hash = "sha256-ji7SppKdiszaXs8yCSIPkJj4Ld++XWNw9FuxLoFLfFo="; 27 }; 28in 29buildPythonPackage (finalAttrs: { 30 pname = "pydicom"; 31 version = "3.0.1"; 32 pyproject = true; 33 34 src = fetchFromGitHub { 35 owner = "pydicom"; 36 repo = "pydicom"; 37 tag = "v${finalAttrs.version}"; 38 hash = "sha256-SvRevQehRaSp+vCtJRQVEJiC5noIJS+bGG1/q4p7/XU="; 39 }; 40 41 build-system = [ flit-core ]; 42 43 dependencies = [ 44 numpy 45 ]; 46 47 optional-dependencies = { 48 pixeldata = [ 49 pillow 50 pyjpegls 51 pylibjpeg 52 pylibjpeg-libjpeg 53 gdcm 54 ] 55 ++ pylibjpeg.optional-dependencies.openjpeg 56 ++ pylibjpeg.optional-dependencies.rle; 57 }; 58 59 nativeCheckInputs = [ 60 pytestCheckHook 61 writableTmpDirAsHomeHook 62 ] 63 ++ finalAttrs.passthru.optional-dependencies.pixeldata; 64 65 passthru.pydicom-data = test_data; 66 67 doCheck = false; # circular dependency 68 69 passthru.tests.pytest = pydicom.overridePythonAttrs { 70 doCheck = true; 71 }; 72 73 # Setting $HOME to prevent pytest to try to create a folder inside 74 # /homeless-shelter which is read-only. 75 # Linking pydicom-data dicom files to $HOME/.pydicom/data 76 preCheck = '' 77 mkdir -p $HOME/.pydicom/ 78 ln -s ${test_data}/data_store/data $HOME/.pydicom/data 79 ''; 80 81 disabledTests = [ 82 # tries to remove a dicom inside $HOME/.pydicom/data/ and download it again 83 "test_fetch_data_files" 84 85 # test_reference_expl{,_binary}[parametric_map_float.dcm] tries to download that file for some reason even though it's present in test-data 86 "test_reference_expl" 87 "test_reference_expl_binary" 88 89 # slight error in regex matching 90 "test_no_decoders_raises" 91 "test_deepcopy_bufferedreader_raises" 92 ] 93 ++ lib.optionals stdenv.hostPlatform.isAarch64 [ 94 # https://github.com/pydicom/pydicom/issues/1386 95 "test_array" 96 ] 97 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 98 # flaky, hard to reproduce failure outside hydra 99 "test_time_check" 100 ]; 101 102 pythonImportsCheck = [ "pydicom" ]; 103 104 meta = { 105 description = "Python package for working with DICOM files"; 106 mainProgram = "pydicom"; 107 homepage = "https://pydicom.github.io"; 108 changelog = "https://github.com/pydicom/pydicom/releases/tag/${finalAttrs.src.tag}"; 109 license = lib.licenses.mit; 110 maintainers = with lib.maintainers; [ bcdarwin ]; 111 }; 112})