1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, numpy
6, pillow
7, zbar
8, pytestCheckHook
9}:
10
11buildPythonPackage rec {
12 pname = "pyzbar";
13 version = "0.1.9";
14
15 src = fetchFromGitHub {
16 owner = "NaturalHistoryMuseum";
17 repo = "pyzbar";
18 rev = "v${version}";
19 sha256 = "8IZQY6qB4r1SUPItDlTDnVQuPs0I38K3yJ6LiPJuwbU=";
20 };
21
22 propagatedBuildInputs = [ zbar pillow numpy ];
23
24 nativeCheckInputs = [ pytestCheckHook ];
25
26 # find_library doesn't return an absolute path
27 # https://github.com/NixOS/nixpkgs/issues/7307
28 postPatch = ''
29 substituteInPlace pyzbar/zbar_library.py \
30 --replace \
31 "find_library('zbar')" \
32 '"${lib.getLib zbar}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary}"'
33 '';
34
35 disabledTests = [
36 # find_library has been replaced by a hardcoded path
37 # the test fails due to find_library not called
38 "test_found_non_windows"
39 "test_not_found_non_windows"
40 ];
41
42 pythonImportsCheck = [ "pyzbar" ];
43
44 meta = with lib; {
45 description = "Read one-dimensional barcodes and QR codes from Python using the zbar library.";
46 homepage = "https://github.com/NaturalHistoryMuseum/pyzbar";
47 license = licenses.mit;
48 maintainers = with maintainers; [ gador ];
49 };
50}