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
065bddbc6c
Reformat with ruff format
2024-04-07 00:25:32 -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
4924b11b6b
Additional ruff fixes
2023-04-14 01:25:16 -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
8a3b82e364
Make Python 3.8 minimum requirement
2022-08-02 14:46:01 -07:00
James R. Barlow
580822a6a2
Fix Windows ghostscript path scanning
2022-08-02 14:39:23 -07:00
James R. Barlow
9f3a52fd12
windows: compare Ghostscript versions properly
2022-08-01 13:58:24 -07:00
James R. Barlow
52e829d845
windows: tidy path shimming
2022-08-01 13:23:57 -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
27f7b9f255
Fix missing TypeAlias on <3.10
2022-07-25 16:32:55 -07:00
James R. Barlow
6f31a92ffb
_windows: Avoid messy next()/StopIteration in generator
2022-07-23 15:40:05 -07:00
James R. Barlow
da2276788c
Fix _windows module typing
2022-07-23 15:32:14 -07:00
James R. Barlow
dc6f1a266a
Modernize type annotations
2022-07-23 00:39:24 -07:00
James R. Barlow
9c8ddd853d
Typing adjustments
2022-07-23 00:07:50 -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
d8753dc790
Fix Windows issue if no exception
2022-06-13 01:46:59 -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 Barlow
776ada6713
Upgrade pre-commit and associated tools; various lints
2022-04-03 20:53:01 -07:00
James R. Barlow
dbfceba020
Standardize ghostscript version default
2021-12-18 02:01:42 -08: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
f8fadaef41
_windows: remove use of deprecated distutils
2021-12-13 20:45:54 -08:00
James R. Barlow
7ce1692eef
windows: default version to '0' when looking for Ghostscript
...
To avoid ValueError: max() arg is an empty sequence
As suggested by @meet1919 in #833 .
2021-11-14 23:00:08 -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