From 76ad975840904c509df250d38b131ef7b052eba2 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 16 Nov 2018 18:44:07 +0100 Subject: pythonPackages.pytesseract: init at 0.2.5 Simple python wrapper for Tesseract, an OCR engine to detect and read text from images. See https://pypi.org/project/pytesseract/ --- .../python-modules/pytesseract/default.nix | 31 ++++++++++++++++++++++ .../pytesseract/tesseract-binary.patch | 13 +++++++++ 2 files changed, 44 insertions(+) create mode 100644 pkgs/development/python-modules/pytesseract/default.nix create mode 100644 pkgs/development/python-modules/pytesseract/tesseract-binary.patch (limited to 'pkgs/development/python-modules/pytesseract') diff --git a/pkgs/development/python-modules/pytesseract/default.nix b/pkgs/development/python-modules/pytesseract/default.nix new file mode 100644 index 000000000000..7d96f4d39bd0 --- /dev/null +++ b/pkgs/development/python-modules/pytesseract/default.nix @@ -0,0 +1,31 @@ +{ buildPythonPackage, fetchPypi, lib, pillow, tesseract, substituteAll }: + +buildPythonPackage rec { + pname = "pytesseract"; + version = "0.2.5"; + + src = fetchPypi { + inherit pname version; + sha256 = "0wlz1vbg1k8cdrpzvrahjnbsfs4ki6xqhbkv17ycfchh7h6kfkfm"; + }; + + patches = [ + (substituteAll { + src = ./tesseract-binary.patch; + drv = "${tesseract}"; + }) + ]; + + buildInputs = [ tesseract ]; + propagatedBuildInputs = [ pillow ]; + + # the package doesn't have any tests. + doCheck = false; + + meta = with lib; { + homepage = https://pypi.org/project/pytesseract/; + license = licenses.gpl3; + description = "A Python wrapper for Google Tesseract"; + maintainers = with maintainers; [ ma27 ]; + }; +} diff --git a/pkgs/development/python-modules/pytesseract/tesseract-binary.patch b/pkgs/development/python-modules/pytesseract/tesseract-binary.patch new file mode 100644 index 000000000000..f7eb9fb1d42a --- /dev/null +++ b/pkgs/development/python-modules/pytesseract/tesseract-binary.patch @@ -0,0 +1,13 @@ +diff --git a/src/pytesseract.py b/src/pytesseract.py +index 32713cf..5f9209d 100755 +--- a/src/pytesseract.py ++++ b/src/pytesseract.py +@@ -25,7 +25,7 @@ if numpy_installed: + from numpy import ndarray + + # CHANGE THIS IF TESSERACT IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY +-tesseract_cmd = 'tesseract' ++tesseract_cmd = '@drv@/bin/tesseract' + RGB_MODE = 'RGB' + OSD_KEYS = { + 'Page number': ('page_num', int), -- cgit 1.4.1