diff --git a/pkgs/development/python-modules/pylibdmtx/default.nix b/pkgs/development/python-modules/pylibdmtx/default.nix new file mode 100644 index 0000000000000..2152ac54241d4 --- /dev/null +++ b/pkgs/development/python-modules/pylibdmtx/default.nix @@ -0,0 +1,47 @@ +{ fetchFromGitHub +, buildPythonPackage +, pillow +, numpy +, libdmtx +, lib +}: + +buildPythonPackage rec { + pname = "pylibdmtx"; + version = "0.1.10"; + + 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 ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 81a0dd25aba23..637f9640bd57d 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7868,6 +7868,8 @@ in { pylibconfig2 = callPackage ../development/python-modules/pylibconfig2 { }; + pylibdmtx = callPackage ../development/python-modules/pylibdmtx { }; + pylibftdi = callPackage ../development/python-modules/pylibftdi { inherit (pkgs) libusb1; };