biome: 1.9.2 -> 1.9.3 (#349335)
[NixPkgs.git] / pkgs / development / python-modules / pillow-heif / default.nix
blob5c8488b9f17ce4f1ef107b46690278bdd0d9002c
2   lib,
3   stdenv,
4   buildPythonPackage,
5   fetchFromGitHub,
6   fetchpatch2,
8   # build-system
9   cmake,
10   nasm,
11   pkg-config,
12   setuptools,
14   # native dependencies
15   libheif,
16   libaom,
17   libde265,
18   x265,
20   # dependencies
21   pillow,
23   # tests
24   opencv4,
25   numpy,
26   pympler,
27   pytestCheckHook,
30 buildPythonPackage rec {
31   pname = "pillow-heif";
32   version = "0.17.0";
33   pyproject = true;
35   src = fetchFromGitHub {
36     owner = "bigcat88";
37     repo = "pillow_heif";
38     rev = "refs/tags/v${version}";
39     hash = "sha256-fKh4UbTVj74YxH2vvL24DNmMxg10GSYAmduwuRneE+0=";
40   };
42   patches = [
43     (fetchpatch2 {
44       # fix libheif 1.18 support in tests
45       url = "https://github.com/bigcat88/pillow_heif/commit/a59434e9ca1138e47e322ddef2adc79e684384f1.patch";
46       hash = "sha256-yVT/pnO5KWMnsO95EPCZgyhx6FIJOhsna7t0zpTjWpE=";
47     })
48   ];
50   postPatch = ''
51     sed -i '/addopts/d' pyproject.toml
52   '';
54   nativeBuildInputs = [
55     cmake
56     nasm
57     pkg-config
58     setuptools
59   ];
61   dontUseCmakeConfigure = true;
63   buildInputs = [
64     libaom
65     libde265
66     libheif
67     x265
68   ];
70   env = {
71     # clang-16: error: argument unused during compilation: '-fno-strict-overflow'
72     NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument";
74     RELEASE_FULL_FLAG = 1;
75   };
77   propagatedBuildInputs = [ pillow ];
79   pythonImportsCheck = [ "pillow_heif" ];
81   nativeCheckInputs = [
82     opencv4
83     numpy
84     pympler
85     pytestCheckHook
86   ];
88   disabledTests =
89     [
90       # Time based
91       "test_decode_threads"
92     ]
93     ++ lib.optionals stdenv.hostPlatform.isDarwin [
94       # https://github.com/bigcat88/pillow_heif/issues/89
95       # not reproducible in nixpkgs
96       "test_opencv_crash"
97     ]
98     ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
99       # RuntimeError: Encoder plugin generated an error: Unsupported bit depth: Bit depth not supported by x265
100       "test_open_heif_compare_non_standard_modes_data"
101       "test_open_save_disable_16bit"
102       "test_save_bgr_16bit_to_10_12_bit"
103       "test_save_bgra_16bit_to_10_12_bit"
104       "test_premultiplied_alpha"
105       "test_hdr_save"
106       "test_I_color_modes_to_10_12_bit"
107     ];
109   meta = {
110     changelog = "https://github.com/bigcat88/pillow_heif/releases/tag/v${version}";
111     description = "Python library for working with HEIF images and plugin for Pillow";
112     homepage = "https://github.com/bigcat88/pillow_heif";
113     license = with lib.licenses; [
114       bsd3
115       lgpl3
116     ];
117     maintainers = with lib.maintainers; [ dandellion ];
118   };