summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyzbar/default.nix
blob: 4ba523f6b21a17a7a3c07bf67124ba4a14caac70 (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
{ lib, buildPythonPackage, fetchFromGitHub, numpy, pillow, zbar, pytestCheckHook }:

buildPythonPackage rec {
  pname = "pyzbar";
  version = "0.1.9";

  src = fetchFromGitHub {
    owner = "NaturalHistoryMuseum";
    repo = "pyzbar";
    rev = "v${version}";
    sha256 = "8IZQY6qB4r1SUPItDlTDnVQuPs0I38K3yJ6LiPJuwbU=";
  };

  propagatedBuildInputs = [ zbar pillow numpy ];

  checkInputs = [ pytestCheckHook ];

  # find_library doesn't return an absolute path
  # https://github.com/NixOS/nixpkgs/issues/7307
  postPatch = ''
    substituteInPlace pyzbar/zbar_library.py \
      --replace "find_library('zbar')" "'${lib.getLib zbar}/lib/libzbar.so.0'"
  '';

  disabledTests = [
    # find_library has been replaced by a hardcoded path
    # the test fails due to find_library not called
    "test_found_non_windows"
    "test_not_found_non_windows"
  ];

  pythonImportsCheck = [ "pyzbar" ];

  meta = with lib; {
    description = "Read one-dimensional barcodes and QR codes from Python using the zbar library.";
    homepage = "https://github.com/NaturalHistoryMuseum/pyzbar";
    license = licenses.mit;
    maintainers = with maintainers; [ gador ];
  };
}