Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 19.03 3.6 kB view raw
1Index: current/src/pyocr/cuneiform.py 2=================================================================== 3--- current.orig/src/pyocr/cuneiform.py 4+++ current/src/pyocr/cuneiform.py 5@@ -27,13 +27,9 @@ from . import error 6 from . import util 7 8 9-# CHANGE THIS IF CUNEIFORM IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY 10-CUNEIFORM_CMD = 'cuneiform' 11+CUNEIFORM_CMD = '@cuneiform@/bin/cuneiform' 12 13-CUNEIFORM_DATA_POSSIBLE_PATHS = [ 14- "/usr/local/share/cuneiform", 15- "/usr/share/cuneiform", 16-] 17+CUNEIFORM_DATA_POSSIBLE_PATHS = ['@cuneiform@/share/cuneiform'] 18 19 LANGUAGES_LINE_PREFIX = "Supported languages: " 20 LANGUAGES_SPLIT_RE = re.compile("[^a-z]") 21Index: current/src/pyocr/libtesseract/tesseract_raw.py 22=================================================================== 23--- current.orig/src/pyocr/libtesseract/tesseract_raw.py 24+++ current/src/pyocr/libtesseract/tesseract_raw.py 25@@ -1,52 +1,13 @@ 26 import ctypes 27 import logging 28 import os 29-import sys 30 31 from ..error import TesseractError 32 33 34 logger = logging.getLogger(__name__) 35 36-TESSDATA_PREFIX = os.getenv('TESSDATA_PREFIX', None) 37-libnames = [] 38- 39-if getattr(sys, 'frozen', False): 40- # Pyinstaller integration 41- libnames += [os.path.join(sys._MEIPASS, "libtesseract-4.dll")] 42- libnames += [os.path.join(sys._MEIPASS, "libtesseract-3.dll")] 43- tessdata = os.path.join(sys._MEIPASS, "data") 44- if not os.path.exists(os.path.join(tessdata, "tessdata")): 45- logger.warning( 46- "Running from container, but no tessdata ({}) found !".format( 47- tessdata 48- ) 49- ) 50- else: 51- TESSDATA_PREFIX = tessdata 52- 53- 54-if sys.platform[:3] == "win": 55- libnames += [ 56- # Jflesch> Don't they have the equivalent of LD_LIBRARY_PATH on 57- # Windows ? 58- "../vs2010/DLL_Release/libtesseract302.dll", 59- # prefer the most recent first 60- "libtesseract305.dll", 61- "libtesseract304.dll", 62- "libtesseract303.dll", 63- "libtesseract302.dll", 64- "libtesseract400.dll", # Tesseract 4 is still in alpha stage 65- "libtesseract.dll", 66- "C:\\Program Files (x86)\\Tesseract-OCR\\libtesseract-4.dll", 67- "C:\\Program Files (x86)\\Tesseract-OCR\\libtesseract-3.dll", 68- ] 69-else: 70- libnames += [ 71- "libtesseract.so.4", 72- "libtesseract.so.3", 73- ] 74- 75+libnames = [ "@tesseract@/lib/libtesseract.so" ] 76 77 g_libtesseract = None 78 79@@ -346,12 +307,11 @@ def init(lang=None): 80 try: 81 if lang: 82 lang = lang.encode("utf-8") 83- prefix = None 84- if TESSDATA_PREFIX: 85- prefix = TESSDATA_PREFIX.encode("utf-8") 86+ prefix = os.getenv('TESSDATA_PREFIX', '@tesseract@/share/tessdata') 87+ os.environ['TESSDATA_PREFIX'] = prefix 88 g_libtesseract.TessBaseAPIInit3( 89 ctypes.c_void_p(handle), 90- ctypes.c_char_p(prefix), 91+ ctypes.c_char_p(prefix.encode('utf-8')), 92 ctypes.c_char_p(lang) 93 ) 94 g_libtesseract.TessBaseAPISetVariable( 95Index: current/src/pyocr/tesseract.py 96=================================================================== 97--- current.orig/src/pyocr/tesseract.py 98+++ current/src/pyocr/tesseract.py 99@@ -31,8 +31,7 @@ from .builders import DigitBuilder # ba 100 from .error import TesseractError # backward compatibility 101 from .util import digits_only 102 103-# CHANGE THIS IF TESSERACT IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY 104-TESSERACT_CMD = 'tesseract.exe' if os.name == 'nt' else 'tesseract' 105+TESSERACT_CMD = '@tesseract@/bin/tesseract' 106 107 TESSDATA_EXTENSION = ".traineddata" 108