Commit 31acaf6d authored by Jerome Flesch's avatar Jerome Flesch

Merge branch 'master' of gitlab.gnome.org:World/OpenPaperwork/pyocr

parents a783e91d 65fa173e
Pipeline #104725 passed with stage
in 8 minutes
22/06/2019 - 0.7.2:
- Fix setup.py on Windows
22/06/2019 - 0.7.1:
- tesseract.can_detect_orientation(): only returns True if 'osd' date files are
installed
- setup.py: Fix installation in MSYS2
12/05/2019 - 0.7:
- Drop support for Python <= 2.7
- Fix: Make sure the builder objects can be used to parse box files
......
......@@ -21,9 +21,9 @@ Make sure you have pip >= 9.0.1.
if os.name == 'nt':
# setuptools_scm doesn't work in MSYS2
setup_deps = []
scm_version = {}
# setuptools_scm doesn't work in MSYS2
if not os.path.exists('src/pyocr/_version.py'):
version = subprocess.run(
'git describe --always',
......@@ -36,8 +36,11 @@ if os.name == 'nt':
fd.write("version = '{}'\n".format(version))
else:
with open("src/pyocr/_version.py", "r") as fd:
version = fd.read().strip()
version = version.split(" ")[2][1:-1]
for line in fd.readlines():
if line[0] != '#' and line.strip() != '':
version = line.strip()
version = version.split(" ")[2][1:-1]
break
else:
setup_deps = [
'setuptools_scm',
......@@ -51,8 +54,12 @@ else:
setup(
name="pyocr",
description=("A Python wrapper for OCR engines (Tesseract, Cuneiform,"
" etc)"),
description=(
"A Python wrapper for OCR engines (Tesseract, Cuneiform, etc)"
),
long_description=(
"A Python wrapper for OCR engines (Tesseract, Cuneiform, etc)"
),
keywords="tesseract cuneiform ocr",
version=version,
url="https://gitlab.gnome.org/World/OpenPaperwork/pyocr",
......@@ -84,7 +91,7 @@ setup(
},
data_files=[],
scripts=[],
zip_safe=True,
zip_safe=(os.name != 'nt'),
python_requires='>=3.4',
install_requires=[
"Pillow",
......
......@@ -119,8 +119,7 @@ def _set_environment():
if getattr(sys, 'frozen', False): # pragma: no cover
# Pyinstaller support
path = os.environ["PATH"]
if sys._MEIPASS in path:
if 'TESSDATA_PREFIX' in os.environ:
# already changed
return
......@@ -128,15 +127,6 @@ def _set_environment():
tessprefix = os.path.join(sys._MEIPASS, "data")
logger.info("Running in packaged environment")
if not os.path.exists(os.path.join(tessprefix, "tessdata")):
logger.warning(
"Running from container, but no tessdata ({}) found !".format(
tessprefix
)
)
else:
logger.info("TESSDATA_PREFIX set to [{}]".format(tessprefix))
os.environ['TESSDATA_PREFIX'] = tessprefix
if not os.path.exists(tesspath):
logger.warning(
"Running from container, but no tesseract ({}) found !".format(
......@@ -149,6 +139,19 @@ def _set_environment():
tesspath + os.pathsep + os.environ['PATH']
)
if not os.path.exists(os.path.join(tessprefix, "tessdata")):
logger.warning(
"Running from container, but no tessdata ({}) found !".format(
tessprefix
)
)
else:
version = get_version(set_env=False)
if version[0] > 3:
tessprefix = os.path.join(tessprefix, "tessdata")
logger.info("TESSDATA_PREFIX set to [{}]".format(tessprefix))
os.environ['TESSDATA_PREFIX'] = tessprefix
def can_detect_orientation():
version = get_version()
......@@ -413,7 +416,7 @@ def get_available_languages():
return [lang for lang in langs if lang and lang[-1] != ':']
def get_version():
def get_version(set_env=True):
"""
Returns Tesseract version.
......@@ -428,7 +431,8 @@ def get_version():
if g_version is not None:
return g_version
_set_environment()
if set_env:
_set_environment()
command = [TESSERACT_CMD, "-v"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment