2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
python,
|
|
|
|
fetchFromGitHub,
|
|
|
|
fetchpatch,
|
|
|
|
cython ? null,
|
|
|
|
numpy ? null,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage {
|
|
|
|
pname = "purepng";
|
|
|
|
version = "0.2.0";
|
2024-01-02 11:29:13 +00:00
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Scondo";
|
|
|
|
repo = "purepng";
|
|
|
|
rev = "449aa00e97a8d7b8a200eb9048056d4da600a345";
|
|
|
|
sha256 = "105p7sxn2f21icfnqpah69mnd74r31szj330swbpz53k7gr6nlsv";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-py37-stopiteration-in-generators.patch";
|
|
|
|
url = "https://github.com/Scondo/purepng/pull/28/commits/62d71dfc2be9ffdc4b3e5f642af0281a8ce8f946.patch";
|
|
|
|
sha256 = "1ag0pji3p012hmj8kadcd0vydv9702188c0isizsi964qcl4va6m";
|
|
|
|
})
|
|
|
|
];
|
2024-06-05 15:53:02 +00:00
|
|
|
patchFlags = [
|
|
|
|
"-p1"
|
|
|
|
"-d"
|
|
|
|
"code"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# cython is optional - if not supplied, the "pure python" implementation will be used
|
|
|
|
nativeBuildInputs = [ cython ];
|
|
|
|
|
|
|
|
# numpy is optional - if not supplied, tests simply have less coverage
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ numpy ];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace code/test_png.py \
|
|
|
|
--replace numpy.bool bool
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# checkPhase begins by deleting source dir to force test execution against installed version
|
|
|
|
checkPhase = ''
|
2023-05-24 13:37:59 +00:00
|
|
|
runHook preCheck
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
rm -r code/png
|
|
|
|
${python.interpreter} code/test_png.py
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
runHook postCheck
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Pure Python library for PNG image encoding/decoding";
|
2023-05-24 13:37:59 +00:00
|
|
|
homepage = "https://github.com/scondo/purepng";
|
|
|
|
license = licenses.mit;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ ris ];
|
|
|
|
};
|
|
|
|
}
|