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