Files
nixpkgs/pkgs/development/python-modules/pydicom/default.nix
T
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

89 lines
2.2 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
flit-core,
numpy,
pillow,
pytestCheckHook,
pythonOlder,
setuptools,
}:
let
pname = "pydicom";
version = "2.4.4";
src = fetchFromGitHub {
owner = "pydicom";
repo = "pydicom";
rev = "refs/tags/v${version}";
hash = "sha256-iJE1horEmdL7bKPn+NlZLgmtCbLZCZWQ8NjDBQPzXk8=";
};
# Pydicom needs pydicom-data to run some tests. If these files aren't downloaded
# before the package creation, it'll try to download during the checkPhase.
test_data = fetchFromGitHub {
owner = "pydicom";
repo = "pydicom-data";
rev = "cbb9b2148bccf0f550e3758c07aca3d0e328e768";
hash = "sha256-nF/j7pfcEpWHjjsqqTtIkW8hCEbuQ3J4IxpRk0qc1CQ=";
};
in
buildPythonPackage {
inherit pname version src;
pyproject = true;
disabled = pythonOlder "3.10";
patches = [
# backport of https://github.com/pydicom/pydicom/commit/2513a20cc41743a42bdb86f4cbb4873899b7823c
./pillow-10.1.0-compat.patch
];
nativeBuildInputs = [ flit-core ];
propagatedBuildInputs = [
numpy
pillow
setuptools
];
nativeCheckInputs = [ pytestCheckHook ];
# Setting $HOME to prevent pytest to try to create a folder inside
# /homeless-shelter which is read-only.
# Linking pydicom-data dicom files to $HOME/.pydicom/data
preCheck = ''
export HOME=$TMP/test-home
mkdir -p $HOME/.pydicom/
ln -s ${test_data}/data_store/data $HOME/.pydicom/data
'';
disabledTests =
[
# tries to remove a dicom inside $HOME/.pydicom/data/ and download it again
"test_fetch_data_files"
]
++ lib.optionals stdenv.hostPlatform.isAarch64 [
# https://github.com/pydicom/pydicom/issues/1386
"test_array"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# flaky, hard to reproduce failure outside hydra
"test_time_check"
];
pythonImportsCheck = [ "pydicom" ];
meta = with lib; {
description = "Python package for working with DICOM files";
mainProgram = "pydicom";
homepage = "https://pydicom.github.io";
changelog = "https://github.com/pydicom/pydicom/releases/tag/v${version}";
license = licenses.mit;
maintainers = with maintainers; [ bcdarwin ];
};
}