about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/pyinsane2/default.nix
blob: 8f96ebe915a6c5575f4270fc908c2f7d672495c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ stdenv
, buildPythonPackage
, fetchPypi
, nose
, pillow
, pkgs
}:

buildPythonPackage rec {
  pname = "pyinsane2";
  version = "2.0.13";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0d519531d552e4512776225eb400a6a4a9bfc83a08918ec7fea19cb2fa7ec4ee";
  };

  # This is needed by setup.py regardless of whether tests are enabled.
  buildInputs = [ nose ];
  propagatedBuildInputs = [ pillow ];

  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))
    }' pyinsane2/sane/abstract_proc.py

    sed -i -e 's,"libsane.so.1","${pkgs.sane-backends}/lib/libsane.so",' \
      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()'
  '';

  meta = with stdenv.lib; {
    homepage = "https://github.com/jflesch/pyinsane";
    description = "Access and use image scanners";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
  };

}