2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
2024-07-31 10:19:44 +00:00
|
|
|
fetchpatch2,
|
2024-06-05 15:53:02 +00:00
|
|
|
|
|
|
|
# build-system
|
|
|
|
cmake,
|
|
|
|
nasm,
|
|
|
|
pkg-config,
|
|
|
|
setuptools,
|
|
|
|
|
|
|
|
# native dependencies
|
|
|
|
libheif,
|
|
|
|
libaom,
|
|
|
|
libde265,
|
|
|
|
x265,
|
|
|
|
|
|
|
|
# dependencies
|
|
|
|
pillow,
|
|
|
|
|
|
|
|
# tests
|
|
|
|
opencv4,
|
|
|
|
numpy,
|
|
|
|
pympler,
|
|
|
|
pytestCheckHook,
|
2023-10-09 19:29:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2023-11-16 04:20:00 +00:00
|
|
|
pname = "pillow-heif";
|
2024-07-31 10:19:44 +00:00
|
|
|
version = "0.17.0";
|
2024-04-21 15:54:59 +00:00
|
|
|
pyproject = true;
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "bigcat88";
|
|
|
|
repo = "pillow_heif";
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-07-31 10:19:44 +00:00
|
|
|
hash = "sha256-fKh4UbTVj74YxH2vvL24DNmMxg10GSYAmduwuRneE+0=";
|
2023-10-09 19:29:22 +00:00
|
|
|
};
|
|
|
|
|
2024-07-31 10:19:44 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch2 {
|
|
|
|
# fix libheif 1.18 support in tests
|
|
|
|
url = "https://github.com/bigcat88/pillow_heif/commit/a59434e9ca1138e47e322ddef2adc79e684384f1.patch";
|
|
|
|
hash = "sha256-yVT/pnO5KWMnsO95EPCZgyhx6FIJOhsna7t0zpTjWpE=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
postPatch = ''
|
|
|
|
sed -i '/addopts/d' pyproject.toml
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
nasm
|
2024-01-13 08:15:51 +00:00
|
|
|
pkg-config
|
2024-04-21 15:54:59 +00:00
|
|
|
setuptools
|
2023-11-16 04:20:00 +00:00
|
|
|
];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
dontUseCmakeConfigure = true;
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
buildInputs = [
|
|
|
|
libaom
|
|
|
|
libde265
|
|
|
|
libheif
|
|
|
|
x265
|
|
|
|
];
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
env = {
|
|
|
|
# clang-16: error: argument unused during compilation: '-fno-strict-overflow'
|
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument";
|
|
|
|
|
|
|
|
RELEASE_FULL_FLAG = 1;
|
|
|
|
};
|
2024-02-29 20:09:43 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
propagatedBuildInputs = [ pillow ];
|
2023-11-16 04:20:00 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "pillow_heif" ];
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
opencv4
|
|
|
|
numpy
|
|
|
|
pympler
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
disabledTests =
|
|
|
|
[
|
|
|
|
# Time based
|
|
|
|
"test_decode_threads"
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
2024-06-05 15:53:02 +00:00
|
|
|
# https://github.com/bigcat88/pillow_heif/issues/89
|
|
|
|
# not reproducible in nixpkgs
|
|
|
|
"test_opencv_crash"
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
|
2024-06-05 15:53:02 +00:00
|
|
|
# RuntimeError: Encoder plugin generated an error: Unsupported bit depth: Bit depth not supported by x265
|
|
|
|
"test_open_heif_compare_non_standard_modes_data"
|
|
|
|
"test_open_save_disable_16bit"
|
|
|
|
"test_save_bgr_16bit_to_10_12_bit"
|
|
|
|
"test_save_bgra_16bit_to_10_12_bit"
|
|
|
|
"test_premultiplied_alpha"
|
|
|
|
"test_hdr_save"
|
|
|
|
"test_I_color_modes_to_10_12_bit"
|
|
|
|
];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
meta = {
|
2023-11-16 04:20:00 +00:00
|
|
|
changelog = "https://github.com/bigcat88/pillow_heif/releases/tag/v${version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
description = "Python library for working with HEIF images and plugin for Pillow";
|
|
|
|
homepage = "https://github.com/bigcat88/pillow_heif";
|
2024-06-05 15:53:02 +00:00
|
|
|
license = with lib.licenses; [
|
|
|
|
bsd3
|
|
|
|
lgpl3
|
|
|
|
];
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = with lib.maintainers; [ dandellion ];
|
|
|
|
};
|
|
|
|
}
|