summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/zxing-cpp/default.nix
blob: 35c96d1fa444cf4f6cc38b3318bfb8dad896818a (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
{
  buildPythonPackage,
  cmake,
  setuptools-scm,
  numpy,
  pillow,
  pybind11,
  libzxing-cpp,
  pytestCheckHook,
  libzint,
}:

buildPythonPackage rec {
  pname = "zxing-cpp";
  inherit (libzxing-cpp) src version meta;
  pyproject = true;

  sourceRoot = "${src.name}/wrappers/python";

  # we don't need pybind11 in the root environment
  # https://pybind11.readthedocs.io/en/stable/installing.html#include-with-pypi
  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "pybind11[global]" "pybind11"

    substituteInPlace setup.py \
      --replace-fail "cfg = 'Debug' if self.debug else 'Release'" "cfg = 'Release'" \
      --replace-fail " '-DVERSION_INFO=' + self.distribution.get_version()]" " '-DVERSION_INFO=' + self.distribution.get_version(), '-DZXING_DEPENDENCIES=LOCAL', '-DZXING_USE_BUNDLED_ZINT=OFF']"
  '';

  dontUseCmakeConfigure = true;

  build-system = [
    setuptools-scm
    pybind11
  ];

  dependencies = [ numpy ];

  nativeBuildInputs = [
    cmake
  ];

  buildInputs = [ libzint ];

  nativeCheckInputs = [
    pillow
    pytestCheckHook
  ];

  enabledTestPaths = [ "test.py" ];

  pythonImportsCheck = [ "zxingcpp" ];
}