James R. Barlow
84f5fe9ee0
Separate probing from execution in _exec and subprocess modules
...
Split ocrmypdf.subprocess/__init__.py into three private submodules by
concern (_run, _version, _check) and reduce __init__ to re-exports.
Introduce ocrmypdf._exec._probe.ToolProbe to centralize the version()/
available() pattern each tool module was reimplementing, so the "is this
tool installed and suitable?" question is cleanly distinct from the
pure, picklable functions that do the work.
Also replace the ghostscript module-import log.addFilter() side effect
with an idempotent _ensure_log_filter_installed() called at the top of
each work function, so the DuplicateFilter is present in subprocess
workers without relying on import-time ordering.
Public API of ocrmypdf.subprocess is unchanged.
2026-04-24 13:33:34 -07:00
James R. Barlow
b2b6a7c4b1
Pass OMP_THREAD_LIMIT to Tesseract subprocesses instead of modifying parent env
...
Instead of setting OMP_THREAD_LIMIT in the parent process's environment,
calculate the thread limit in the validate hook and pass it through to
Tesseract subprocess calls via the env parameter. This avoids polluting
the parent process's environment while still controlling Tesseract's
thread usage.
2026-01-06 18:43:29 -08:00
James R. Barlow
9d042767cc
Attempt to fix matrix and unpaper version error
2024-10-27 14:04:45 -07:00
James R. Barlow
9ba4e3ab46
Log unusual exceptions when trying to obtain a version
...
Fixes #1262
2024-04-07 14:39:08 -07:00
James R. Barlow
6a746a1cbb
ruff linting/Python 3.10 cleanup
2024-02-14 12:41:51 -08:00
James R. Barlow
113a6b45bd
ruff autofixes (mostly typing.* -> collections.abc.*)
2023-10-01 00:02:53 -07:00
James R. Barlow
ea36aedb5f
Overhaul version checkers to prefer Version to str
2023-09-25 00:59:44 -07:00
James R. Barlow
bd4d44e182
Remove Python 3.8 shim for missing str.removeprefix
2023-09-25 00:31:48 -07:00
James R. Barlow
417ee067a2
Remove obsolete universal_newlines check
2023-06-02 02:47:41 -07:00
James R. Barlow
33b70be7d5
ruff: more fixes, mainly missing docstrings
2023-04-14 02:16:38 -07:00
James R. Barlow
9b8d14d16e
Accept most of ruff's delinting
2023-04-14 00:45:34 -07:00
Kian-Meng Ang and GitHub
ba10c5345b
Fix typos ( #1087 )
...
Found via `codespell -S tests,LICENSES -L flate`
2023-03-29 21:57:32 -07:00
James R. Barlow
670ce2b969
Remove support for non-callable version checker
2022-08-04 03:58:10 -07:00
James R. Barlow
2b2e5c271a
Don't lru_cache versions
...
lru_cache could interfere with testing and we don't have evidence this
is slow enough to justify optimizing.
2022-08-01 13:23:31 -07:00
James R. Barlow
c7fcbe9075
Improve Linux install advice
2022-08-01 01:59:40 -07:00
James R. Barlow
80ed2117cc
Change to SPDX license tracking
2022-07-28 01:10:07 -07:00
James R. Barlow
dc6f1a266a
Modernize type annotations
2022-07-23 00:39:24 -07:00
James R. Barlow
b9bffa97ba
Fix ABCMeta typing
2022-07-12 02:20:22 -07:00
James R. Barlow
b1f2d257e2
Typing improvements
2022-07-09 02:24:19 -07:00
James R. Barlow
10245dc954
Refactor a helper to use the Python API eventually
2022-06-12 00:31:01 -07:00
James R. Barlow
b17fb61389
Configure pylint in pyproject and delint
2022-06-12 00:30:44 -07:00
James R. Barlow
0faa618c3c
Replace deprecated distutils with packaging.version
2021-12-18 01:57:59 -08:00
James R. Barlow
7035002c03
Order of operations suppressed detailed Ghostscript missing error message
2021-12-18 01:27:39 -08:00
James R. Barlow
e3126d2806
Adjust test to support Tesseract 5 working harder to find its files
2021-11-13 01:16:35 -08:00
James R. Barlow
380b981763
Remove most Python 3.6 special casing
2021-11-13 00:27:48 -08:00
James R. Barlow
ec311af796
typing: subprocess
2021-09-22 17:18:59 -07:00
James R. Barlow
c725bf79da
flake8 delinting
2021-09-21 16:37:03 -07:00
James R. Barlow
336d274a54
Drop remnants of support for Tesseract without has_textonly_pdf
...
Also improve Tesseract version checking so it can compare all of their
weird conventions.
2021-04-07 23:05:21 -07:00
62e5edc72b
fix unclosed file warnings. ( #710 )
...
Co-authored-by: Jonas Winkler <jonas.winkler@jpwinkler.de >
2021-01-06 03:59:28 -08:00
James R. Barlow
5172dbde8d
subprocess: use more mypy-friendly syntax
2020-12-11 14:14:21 -08:00
James R. Barlow
3cba50bfbd
windows: look in registry for Tesseract and Ghostscript
2020-12-04 13:21:54 -08:00