Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 cmake, 9 nasm, 10 pkg-config, 11 setuptools, 12 13 # native dependencies 14 libheif, 15 libaom, 16 libde265, 17 x265, 18 19 # dependencies 20 pillow, 21 22 # tests 23 opencv4, 24 numpy, 25 pytestCheckHook, 26}: 27 28buildPythonPackage rec { 29 pname = "pillow-heif"; 30 version = "0.22.0"; 31 pyproject = true; 32 33 src = fetchFromGitHub { 34 owner = "bigcat88"; 35 repo = "pillow_heif"; 36 tag = "v${version}"; 37 hash = "sha256-xof6lFb0DhmWVmYuBNslcGZs82NRkcgZgt+SX9gsrBY="; 38 }; 39 40 postPatch = '' 41 sed -i '/addopts/d' pyproject.toml 42 substituteInPlace setup.py \ 43 --replace-warn ', "-Werror"' "" 44 ''; 45 46 nativeBuildInputs = [ 47 cmake 48 nasm 49 pkg-config 50 ]; 51 52 build-system = [ setuptools ]; 53 54 dontUseCmakeConfigure = true; 55 56 buildInputs = [ 57 libaom 58 libde265 59 libheif 60 x265 61 ]; 62 63 env = { 64 RELEASE_FULL_FLAG = 1; 65 }; 66 67 dependencies = [ pillow ]; 68 69 pythonImportsCheck = [ "pillow_heif" ]; 70 71 nativeCheckInputs = [ 72 opencv4 73 numpy 74 pytestCheckHook 75 ]; 76 77 preCheck = '' 78 # https://github.com/bigcat88/pillow_heif/issues/325 79 rm tests/images/heif_other/L_xmp_latin1.heic 80 rm tests/images/heif/L_xmp.heif 81 ''; 82 83 disabledTests = [ 84 # Time based 85 "test_decode_threads" 86 # Missing EXIF info on WEBP-AVIF variant 87 "test_exif_from_pillow" 88 ] 89 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 90 # https://github.com/bigcat88/pillow_heif/issues/89 91 # not reproducible in nixpkgs 92 "test_opencv_crash" 93 ] 94 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [ 95 # RuntimeError: Encoder plugin generated an error: Unsupported bit depth: Bit depth not supported by x265 96 "test_open_heif_compare_non_standard_modes_data" 97 "test_open_save_disable_16bit" 98 "test_save_bgr_16bit_to_10_12_bit" 99 "test_save_bgra_16bit_to_10_12_bit" 100 "test_premultiplied_alpha" 101 "test_hdr_save" 102 "test_I_color_modes_to_10_12_bit" 103 ]; 104 105 meta = { 106 changelog = "https://github.com/bigcat88/pillow_heif/releases/tag/${src.tag}"; 107 description = "Python library for working with HEIF images and plugin for Pillow"; 108 homepage = "https://github.com/bigcat88/pillow_heif"; 109 license = with lib.licenses; [ 110 bsd3 111 lgpl3 112 ]; 113 maintainers = with lib.maintainers; [ dandellion ]; 114 }; 115}