1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pillow,
6 unittestCheckHook,
7 pythonAtLeast,
8}:
9
10buildPythonPackage rec {
11 pname = "diffimg";
12 version = "0.3.0"; # github recognized 0.1.3, there's a v0.1.5 tag and setup.py says 0.3.0
13 format = "setuptools";
14
15 src = fetchFromGitHub {
16 owner = "nicolashahn";
17 repo = "diffimg";
18 rev = "b82f0bb416f100f9105ccccf1995872b29302461";
19 hash = "sha256-H/UQsqyfdnlESBe7yRu6nK/0dakQkAfeFaZNwjCMvdM=";
20 };
21
22 # it imports the wrong diff,
23 # fix offered to upstream https://github.com/nicolashahn/diffimg/pull/6
24 postPatch =
25 ''
26 substituteInPlace diffimg/test.py \
27 --replace-warn "from diff import diff" "from diffimg.diff import diff"
28 ''
29 + lib.optionalString (pythonAtLeast "3.12") ''
30 substituteInPlace diffimg/test.py \
31 --replace-warn "3503192421617232" "3503192421617233"
32 '';
33
34 propagatedBuildInputs = [ pillow ];
35
36 pythonImportsCheck = [ "diffimg" ];
37
38 nativeCheckInputs = [ unittestCheckHook ];
39
40 meta = with lib; {
41 description = "Differentiate images in python - get a ratio or percentage difference, and generate a diff image";
42 homepage = "https://github.com/nicolashahn/diffimg";
43 license = licenses.mit;
44 maintainers = with maintainers; [ evils ];
45 };
46}