From 0409ce23303a0b194a10c1cb81971a03066d7770 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 19 Dec 2016 10:47:33 +0100 Subject: [PATCH] python/pyinsane2: init at 2.0.9 The tests require a scanner to be physically attached. Quote from the upstream README: > Tests require at least one scanner with a flatbed and an ADF > (Automatic Document Feeder). > > If possible, they should be run with at least 2 scanners connected. > The first that appear in "scanimage -L" must be the one with the ADF. > > For reference, my current setup is: > > - HP Officejet 4620 (Flatbed + ADF) > - HP Deskjet 2050 J510 series (Flatbed) So we disable the tests even though it might be theoretically possible to use qemu and an emulated scanner. Instead of the upstream tests we just do a quick check whether initialization of the library succeeds. Other than that the library uses ctypes.cdll to dlopen() the libsane shared library, so we need to patch in the right store path. Tested by building against Python 2.7, 3.3, 3.4, 3.5 and 3.6. Signed-off-by: aszlig --- pkgs/top-level/python-packages.nix | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index f4a425b2673..92554e65471 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -20422,6 +20422,44 @@ in { }; }; + pyinsane2 = buildPythonPackage rec { + name = "pyinsane2-${version}"; + version = "2.0.9"; + + src = pkgs.fetchurl { + url = "mirror://pypi/p/pyinsane2/${name}.tar.gz"; + sha256 = "1g4a1zhrrs7smmnsm7x8j5lvsz0r6rr2jgjykc9c1jlscz3yr747"; + }; + + postPatch = '' + # pyinsane2 forks itself, so we need to re-inject the PYTHONPATH. + sed -i -e '/os.putenv.*PYINSANE_DAEMON/ { + a \ os.putenv("PYTHONPATH", ":".join(sys.path)) + }' src/pyinsane2/sane/abstract_proc.py + + sed -i -e 's,"libsane.so.1","${pkgs.sane-backends}/lib/libsane.so",' \ + src/pyinsane2/sane/rawapi.py + ''; + + # Tests require a scanner to be physically connected, so let's just do a + # quick check whether initialization works. + checkPhase = '' + python -c 'import pyinsane2; pyinsane2.init()' + ''; + + # This is needed by setup.py regardless of whether tests are enabled. + buildInputs = [ self.nose ]; + + propagatedBuildInputs = [ self.pillow ]; + + meta = { + homepage = "https://github.com/jflesch/pyinsane"; + description = "Access and use image scanners"; + license = licenses.gpl3Plus; + platforms = platforms.linux; + }; + }; + pyjwt = buildPythonPackage rec { version = "1.4.2"; name = "pyjwt-${version}";