summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/python-escpos/default.nix
blob: a22e446e8f95a1a2183916265fdd467602e7c040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  setuptools,
  setuptools-scm,

  pillow,
  qrcode,
  python-barcode,
  six,
  appdirs,
  pyyaml,
  argcomplete,
  importlib-resources,

  pyusb,
  pyserial,
  pycups,

  jaconv,
  pytestCheckHook,
  pytest-cov-stub,
  pytest-mock,
  scripttest,
  mock,
  hypothesis,
}:

buildPythonPackage (finalAttrs: {
  pname = "python-escpos";
  version = "3.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "python-escpos";
    repo = "python-escpos";
    tag = "v${finalAttrs.version}";
    hash = "sha256-f7qA1+8PwnXS526jjULEoyn0ejnvsneuWDt863p4J2g=";
    fetchSubmodules = true;
  };

  build-system = [
    setuptools
    setuptools-scm
  ];

  dependencies = [
    pillow
    qrcode
    python-barcode
    six
    appdirs
    pyyaml
    argcomplete
    importlib-resources
  ];

  optional-dependencies = {
    usb = [ pyusb ];
    serial = [ pyserial ];
    cups = [ pycups ];
    all = [
      pyusb
      pyserial
      pycups
    ];
  };

  preCheck = ''
    # force the tests to use the module in $out
    rm -r src

    # allow tests to find the cli executable
    export PATH="$out/bin:$PATH"
  '';

  nativeCheckInputs = [
    jaconv
    pytestCheckHook
    pytest-cov-stub
    pytest-mock
    scripttest
    mock
    hypothesis
  ]
  ++ finalAttrs.passthru.optional-dependencies.all;

  pythonImportsCheck = [ "escpos" ];

  meta = {
    changelog = "https://github.com/python-escpos/python-escpos/blob/${finalAttrs.src.rev}/CHANGELOG.rst";
    description = "Python library to manipulate ESC/POS printers";
    homepage = "https://python-escpos.readthedocs.io/";
    license = lib.licenses.mit;
    mainProgram = "python-escpos";
    maintainers = with lib.maintainers; [ tomasajt ];
  };
})