1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonAtLeast,
6
7 # build-system
8 poetry-core,
9
10 # dependencies
11 pillow,
12 pypng,
13
14 # tests
15 mock,
16 pytestCheckHook,
17 qrcode,
18 testers,
19}:
20
21buildPythonPackage rec {
22 pname = "qrcode";
23 version = "8.2";
24 pyproject = true;
25
26 src = fetchFromGitHub {
27 owner = "lincolnloop";
28 repo = "python-qrcode";
29 tag = "v${version}";
30 hash = "sha256-qLIYUFnBJQGidnfC0bQAkO/aUmT94uXFMeMhnUgUnfQ=";
31 };
32
33 build-system = [ poetry-core ];
34
35 optional-dependencies = {
36 pil = [ pillow ];
37 png = [ pypng ];
38 all = [
39 pypng
40 pillow
41 ];
42 };
43
44 nativeCheckInputs = [
45 mock
46 pytestCheckHook
47 ]
48 ++ lib.flatten (lib.attrValues optional-dependencies);
49
50 passthru.tests = {
51 version = testers.testVersion {
52 package = qrcode;
53 command = "qr --version";
54 };
55 };
56
57 disabledTests = lib.optionals (pythonAtLeast "3.12") [ "test_change" ] ++ [
58 # Attempts to open a file which doesn't exist in sandbox
59 "test_piped"
60 ];
61
62 meta = {
63 description = "Python QR Code image generator";
64 mainProgram = "qr";
65 homepage = "https://github.com/lincolnloop/python-qrcode";
66 changelog = "https://github.com/lincolnloop/python-qrcode/blob/v${version}/CHANGES.rst";
67 license = lib.licenses.bsd3;
68 maintainers = with lib.maintainers; [ attila ];
69 };
70}