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