at master 1.8 kB view raw
1{ 2 buildPythonPackage, 3 fetchPypi, 4 fetchpatch, 5 lib, 6 7 # build-system 8 cython, 9 pkg-config, 10 setuptools, 11 12 # native dependencies 13 leptonica, 14 tesseract4, 15 16 # dependencies 17 pillow, 18 19 # tests 20 unittestCheckHook, 21}: 22 23buildPythonPackage rec { 24 pname = "tesserocr"; 25 version = "2.8.0"; 26 format = "setuptools"; 27 28 src = fetchPypi { 29 inherit pname version; 30 hash = "sha256-vlGNGxtf9UwRqtoeD9EpQlCepwWB4KizmipHOgstvTY="; 31 }; 32 33 patches = [ 34 # Fix a broken test. The issue has been reported upstream at 35 # https://github.com/sirfz/tesserocr/issues/363 36 # Check the status of the issue before removing this patch at the next 37 # update. 38 (fetchpatch { 39 url = "https://github.com/sirfz/tesserocr/commit/78d9e8187bd4d282d572bd5221db2c69e560e017.patch"; 40 hash = "sha256-s51s9EIV9AZT6UoqwTuQ8lOjToqwIIUkDLjsvCsyYFU="; 41 }) 42 ]; 43 44 # https://github.com/sirfz/tesserocr/issues/314 45 postPatch = '' 46 sed -i '/allheaders.h/a\ pass\n\ncdef extern from "leptonica/pix_internal.h" nogil:' tesserocr/tesseract.pxd 47 48 substituteInPlace setup.py \ 49 --replace-fail "Cython>=0.23,<3.1.0" Cython 50 ''; 51 52 build-system = [ 53 cython 54 pkg-config 55 setuptools 56 ]; 57 58 buildInputs = [ 59 leptonica 60 tesseract4 61 ]; 62 63 dependencies = [ pillow ]; 64 65 pythonImportsCheck = [ "tesserocr" ]; 66 67 nativeCheckInputs = [ unittestCheckHook ]; 68 69 preCheck = '' 70 rm -rf tesserocr 71 ''; 72 73 meta = { 74 changelog = "https://github.com/sirfz/tesserocr/releases/tag/v${version}"; 75 description = "Simple, Pillow-friendly, wrapper around the tesseract-ocr API for Optical Character Recognition (OCR)"; 76 homepage = "https://github.com/sirfz/tesserocr"; 77 license = lib.licenses.mit; 78 maintainers = with lib.maintainers; [ mtrsk ]; 79 platforms = lib.platforms.unix; 80 }; 81}