1{ lib
2, buildPythonPackage
3, python
4, fetchFromGitHub
5, fetchpatch
6, cython ? null
7, numpy ? null
8}:
9
10buildPythonPackage {
11 pname = "purepng";
12 version = "0.2.0";
13
14 src = fetchFromGitHub {
15 owner = "Scondo";
16 repo = "purepng";
17 rev = "449aa00e97a8d7b8a200eb9048056d4da600a345";
18 sha256 = "105p7sxn2f21icfnqpah69mnd74r31szj330swbpz53k7gr6nlsv";
19 };
20
21 patches = [
22 (fetchpatch {
23 name = "fix-py37-stopiteration-in-generators.patch";
24 url = "https://github.com/Scondo/purepng/pull/28/commits/62d71dfc2be9ffdc4b3e5f642af0281a8ce8f946.patch";
25 sha256 = "1ag0pji3p012hmj8kadcd0vydv9702188c0isizsi964qcl4va6m";
26 })
27 ];
28 patchFlags = [ "-p1" "-d" "code" ];
29
30 # cython is optional - if not supplied, the "pure python" implementation will be used
31 nativeBuildInputs = [ cython ];
32
33 # numpy is optional - if not supplied, tests simply have less coverage
34 nativeCheckInputs = [ numpy ];
35
36 postPatch = ''
37 substituteInPlace code/test_png.py \
38 --replace numpy.bool bool
39 '';
40
41 # checkPhase begins by deleting source dir to force test execution against installed version
42 checkPhase = ''
43 runHook preCheck
44
45 rm -r code/png
46 ${python.interpreter} code/test_png.py
47
48 runHook postCheck
49 '';
50
51 meta = with lib; {
52 description = "Pure Python library for PNG image encoding/decoding";
53 homepage = "https://github.com/scondo/purepng";
54 license = licenses.mit;
55 maintainers = with maintainers; [ ris ];
56 };
57}