about summary refs log tree commit diff
path: root/pkgs/development/python-modules
diff options
context:
space:
mode:
authorRobert Scott <code@humanleg.org.uk>2019-05-02 22:18:12 +0100
committerRobert Scott <code@humanleg.org.uk>2019-05-03 19:26:40 +0100
commit7451a6a107979c30aff5b0b4a2f6f37dcb980333 (patch)
treefe7cb3cb9b3adf9c1a596aa14a352396275f8c8f /pkgs/development/python-modules
parent11a185b61f3fdc4a7f844f8660735c136a30ee60 (diff)
pythonPackages.purepng: fix for py3.7, enable tests
the pypi package includes pre-cythonized versions of some components,
however these were cythonized with a py3.7-unaware cython which is what
caused the main breakage. fetching the equivalent version from github
allows us to offer either the pure-python version or one we cythonize
ourselves if the cython package is provided.

the added bonus of using a github checkout is that the tests are included,
so enable these.

these tests revealed that for full py3.7 compatibility an additional patch
is needed from an upstream PR.
Diffstat (limited to 'pkgs/development/python-modules')
-rw-r--r--pkgs/development/python-modules/purepng/default.nix34
1 files changed, 30 insertions, 4 deletions
diff --git a/pkgs/development/python-modules/purepng/default.nix b/pkgs/development/python-modules/purepng/default.nix
index 49e4d93a5342f..cecd7cc576d96 100644
--- a/pkgs/development/python-modules/purepng/default.nix
+++ b/pkgs/development/python-modules/purepng/default.nix
@@ -1,17 +1,43 @@
 { stdenv
 , buildPythonPackage
-, fetchPypi
+, python
+, fetchFromGitHub
+, fetchpatch
+, cython ? null
+, numpy ? null
 }:
 
 buildPythonPackage rec {
   pname = "purepng";
   version = "0.2.0";
 
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "1kcl7a6d7d59360fbz2jwfk6ha6pmqgn396962p4s62j893d2r0d";
+  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";
+    })
+  ];
+  patchFlags = "-p1 -d code";
+
+  # 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
+  checkInputs = [ numpy ];
+  # checkPhase begins by deleting source dir to force test execution against installed version
+  checkPhase = ''
+    rm -r code/png
+    ${python.interpreter} code/test_png.py
+  '';
+
   meta = with stdenv.lib; {
     description = "Pure Python library for PNG image encoding/decoding";
     homepage    = https://github.com/scondo/purepng;