1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
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.0";
24 pyproject = true;
25
26 src = fetchPypi {
27 inherit pname version;
28 hash = "sha256-AlzisVD3/kKW0Rbum61FWmZDq09ufc5UFhOkdYy840c=";
29 };
30
31 build-system = [ poetry-core ];
32
33 optional-dependencies = {
34 pil = [ pillow ];
35 png = [ pypng ];
36 all = [
37 pypng
38 pillow
39 ];
40 };
41
42 nativeCheckInputs = [
43 mock
44 pytestCheckHook
45 ] ++ lib.flatten (lib.attrValues optional-dependencies);
46
47 passthru.tests = {
48 version = testers.testVersion {
49 package = qrcode;
50 command = "qr --version";
51 };
52 };
53
54 disabledTests = lib.optionals (pythonAtLeast "3.12") [ "test_change" ] ++ [
55 # Attempts to open a file which doesn't exist in sandbox
56 "test_piped"
57 ];
58
59 meta = with lib; {
60 description = "Python QR Code image generator";
61 mainProgram = "qr";
62 homepage = "https://github.com/lincolnloop/python-qrcode";
63 changelog = "https://github.com/lincolnloop/python-qrcode/blob/v${version}/CHANGES.rst";
64 license = licenses.bsd3;
65 maintainers = [ ];
66 };
67}