1{
2 lib,
3 pkgs,
4 buildPythonPackage,
5 fetchFromGitea,
6 replaceVars,
7 colord,
8 setuptools,
9 pikepdf,
10 pillow,
11 stdenv,
12 exiftool,
13 imagemagick,
14 mupdf-headless,
15 netpbm,
16 numpy,
17 poppler-utils,
18 pytestCheckHook,
19 runCommand,
20 scipy,
21}:
22
23buildPythonPackage rec {
24 pname = "img2pdf";
25 version = "0.6.1";
26 pyproject = true;
27
28 src = fetchFromGitea {
29 domain = "gitlab.mister-muffin.de";
30 owner = "josch";
31 repo = "img2pdf";
32 tag = version;
33 hash = "sha256-71u6ex+UAEFPDtR9QI8Ezah5zCorn4gMdAnzFz4blsI=";
34 };
35
36 patches = [
37 (replaceVars ./default-icc-profile.patch {
38 srgbProfile =
39 if stdenv.hostPlatform.isDarwin then
40 "/System/Library/ColorSync/Profiles/sRGB Profile.icc"
41 else
42 # break runtime dependency chain all of colord dependencies
43 runCommand "sRGC.icc" { } ''
44 cp ${colord}/share/color/icc/colord/sRGB.icc $out
45 '';
46 })
47 ];
48
49 build-system = [ setuptools ];
50
51 dependencies = [
52 pikepdf
53 pillow
54 ];
55
56 # FIXME: Only add "sRGB Profile.icc" to __impureHostDeps once
57 # https://github.com/NixOS/nix/issues/9301 is fixed.
58 __impureHostDeps = lib.optionals stdenv.hostPlatform.isDarwin [
59 "/System/Library/ColorSync/Profiles"
60 ];
61
62 nativeCheckInputs = [
63 exiftool
64 pkgs.ghostscript
65 imagemagick
66 mupdf-headless
67 netpbm
68 numpy
69 poppler-utils
70 pytestCheckHook
71 scipy
72 ];
73
74 preCheck = ''
75 export img2pdfprog="$out/bin/img2pdf"
76 '';
77
78 disabledTests = [
79 # https://gitlab.mister-muffin.de/josch/img2pdf/issues/178
80 "test_jpg_cmyk"
81 "test_miff_cmyk8"
82 "test_tiff_cmyk8"
83 "test_miff_cmyk16"
84 "test_png_gray16"
85 "test_png_rgb16"
86 # these only fail on aarch64
87 "test_png_rgba8"
88 "test_png_gray8a"
89 ];
90
91 pythonImportsCheck = [ "img2pdf" ];
92
93 meta = {
94 changelog = "https://gitlab.mister-muffin.de/josch/img2pdf/src/tag/${src.tag}/CHANGES.rst";
95 description = "Convert images to PDF via direct JPEG inclusion";
96 homepage = "https://gitlab.mister-muffin.de/josch/img2pdf";
97 license = lib.licenses.lgpl3Plus;
98 mainProgram = "img2pdf";
99 maintainers = with lib.maintainers; [
100 veprbl
101 dotlambda
102 ];
103 };
104}