about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pylibdmtx/default.nix
blob: 97037747a25b2008d65a502f66eb7bb6f2e5baf6 (plain) (blame)
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
{
  fetchFromGitHub,
  buildPythonPackage,
  pillow,
  numpy,
  libdmtx,
  lib,
}:

buildPythonPackage rec {
  pname = "pylibdmtx";
  version = "0.1.10";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "NaturalHistoryMuseum";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-vNWzhO4V0mj4eItZ0Z5UG9RBCqprIcgMGNyIe1+mXWY=";
  };

  # Change:
  # def load():
  #     """Loads the libdmtx shared library.
  #
  # To:
  # def load():
  #     return cdll.LoadLibrary("/nix/store/.../lib/libdmtx.so")
  #     """Loads the libdmtx shared library.
  postPatch = ''
    sed -i '\#def load.*#a\    return cdll.LoadLibrary("${libdmtx}/lib/libdmtx.so")' \
        pylibdmtx/dmtx_library.py

    # Checks that the loader works in various scenarios, but we just
    # forced it to only work one way.
    rm pylibdmtx/tests/test_dmtx_library.py
  '';

  propagatedBuildInputs = [
    pillow
    numpy
  ];

  pythonImportsCheck = [ "pylibdmtx" ];

  meta = with lib; {
    description = "Read and write Data Matrix barcodes from Python 2 and 3 using the libdmtx library";
    homepage = "https://github.com/NaturalHistoryMuseum/pylibdmtx/";
    license = licenses.mit;
    maintainers = with maintainers; [ grahamc ];
  };
}