1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pillow,
6 unittestCheckHook,
7 pythonAtLeast,
8}:
9
10buildPythonPackage {
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 substituteInPlace diffimg/test.py \
26 --replace-warn "from diff import diff" "from diffimg.diff import diff"
27 ''
28 + lib.optionalString (pythonAtLeast "3.12") ''
29 substituteInPlace diffimg/test.py \
30 --replace-warn "3503192421617232" "3503192421617233"
31 '';
32
33 propagatedBuildInputs = [ pillow ];
34
35 pythonImportsCheck = [ "diffimg" ];
36
37 nativeCheckInputs = [ unittestCheckHook ];
38
39 meta = with lib; {
40 description = "Differentiate images in python - get a ratio or percentage difference, and generate a diff image";
41 homepage = "https://github.com/nicolashahn/diffimg";
42 license = licenses.mit;
43 maintainers = with maintainers; [ evils ];
44 };
45}