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