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 ] ++ lib.flatten (lib.attrValues optional-dependencies);
48
49 passthru.tests = {
50 version = testers.testVersion {
51 package = qrcode;
52 command = "qr --version";
53 };
54 };
55
56 disabledTests = lib.optionals (pythonAtLeast "3.12") [ "test_change" ] ++ [
57 # Attempts to open a file which doesn't exist in sandbox
58 "test_piped"
59 ];
60
61 meta = {
62 description = "Python QR Code image generator";
63 mainProgram = "qr";
64 homepage = "https://github.com/lincolnloop/python-qrcode";
65 changelog = "https://github.com/lincolnloop/python-qrcode/blob/v${version}/CHANGES.rst";
66 license = lib.licenses.bsd3;
67 maintainers = with lib.maintainers; [ attila ];
68 };
69}