889482aab3
GitOrigin-RevId: f2537a505d45c31fe5d9c27ea9829b6f4c4e6ac5
127 lines
4 KiB
Diff
127 lines
4 KiB
Diff
diff --git a/src/ocrmypdf/_exec/ghostscript.py b/src/ocrmypdf/_exec/ghostscript.py
|
|
index 4da65483..af750249 100644
|
|
--- a/src/ocrmypdf/_exec/ghostscript.py
|
|
+++ b/src/ocrmypdf/_exec/ghostscript.py
|
|
@@ -35,15 +35,7 @@ log = logging.getLogger(__name__)
|
|
# Most reliable what to get the bitness of Python interpreter, according to Python docs
|
|
_IS_64BIT = sys.maxsize > 2**32
|
|
|
|
-_GSWIN = None
|
|
-if os.name == 'nt':
|
|
- if _IS_64BIT:
|
|
- _GSWIN = 'gswin64c'
|
|
- else:
|
|
- _GSWIN = 'gswin32c'
|
|
-
|
|
-GS = _GSWIN if _GSWIN else 'gs'
|
|
-del _GSWIN
|
|
+GS = '@gs@'
|
|
|
|
|
|
def version():
|
|
diff --git a/src/ocrmypdf/_exec/jbig2enc.py b/src/ocrmypdf/_exec/jbig2enc.py
|
|
index 2e8a058b..65a09088 100644
|
|
--- a/src/ocrmypdf/_exec/jbig2enc.py
|
|
+++ b/src/ocrmypdf/_exec/jbig2enc.py
|
|
@@ -14,7 +14,7 @@ from ocrmypdf.subprocess import get_version, run
|
|
|
|
|
|
def version():
|
|
- return get_version('jbig2', regex=r'jbig2enc (\d+(\.\d+)*).*')
|
|
+ return get_version('@jbig2@', regex=r'jbig2enc (\d+(\.\d+)*).*')
|
|
|
|
|
|
def available():
|
|
@@ -27,7 +27,7 @@ def available():
|
|
|
|
def convert_group(*, cwd, infiles, out_prefix):
|
|
args = [
|
|
- 'jbig2',
|
|
+ '@jbig2@',
|
|
'-b',
|
|
out_prefix,
|
|
'-s', # symbol mode (lossy)
|
|
@@ -46,7 +46,7 @@ def convert_group_mp(args):
|
|
|
|
|
|
def convert_single(*, cwd, infile, outfile):
|
|
- args = ['jbig2', '-p', infile]
|
|
+ args = ['@jbig2@', '-p', infile]
|
|
with open(outfile, 'wb') as fstdout:
|
|
proc = run(args, cwd=cwd, stdout=fstdout, stderr=PIPE)
|
|
proc.check_returncode()
|
|
diff --git a/src/ocrmypdf/_exec/pngquant.py b/src/ocrmypdf/_exec/pngquant.py
|
|
index ca8a4542..d0544174 100644
|
|
--- a/src/ocrmypdf/_exec/pngquant.py
|
|
+++ b/src/ocrmypdf/_exec/pngquant.py
|
|
@@ -19,7 +19,7 @@ from ocrmypdf.subprocess import get_version, run
|
|
|
|
|
|
def version():
|
|
- return get_version('pngquant', regex=r'(\d+(\.\d+)*).*')
|
|
+ return get_version('@pngquant@', regex=r'(\d+(\.\d+)*).*')
|
|
|
|
|
|
def available():
|
|
@@ -46,7 +46,7 @@ def input_as_png(input_file: Path):
|
|
def quantize(input_file: Path, output_file: Path, quality_min: int, quality_max: int):
|
|
with input_as_png(input_file) as input_stream:
|
|
args = [
|
|
- 'pngquant',
|
|
+ '@pngquant@',
|
|
'--force',
|
|
'--skip-if-larger',
|
|
'--quality',
|
|
diff --git a/src/ocrmypdf/_exec/tesseract.py b/src/ocrmypdf/_exec/tesseract.py
|
|
index 01177cac..665f1145 100644
|
|
--- a/src/ocrmypdf/_exec/tesseract.py
|
|
+++ b/src/ocrmypdf/_exec/tesseract.py
|
|
@@ -114,7 +114,7 @@ class TesseractVersion(Version):
|
|
|
|
|
|
def version() -> str:
|
|
- return get_version('tesseract', regex=r'tesseract\s(.+)')
|
|
+ return get_version('@tesseract@', regex=r'tesseract\s(.+)')
|
|
|
|
|
|
def has_user_words():
|
|
@@ -141,7 +141,7 @@ def get_languages():
|
|
msg += output
|
|
return msg
|
|
|
|
- args_tess = ['tesseract', '--list-langs']
|
|
+ args_tess = ['@tesseract@', '--list-langs']
|
|
try:
|
|
proc = run(
|
|
args_tess,
|
|
@@ -163,7 +163,7 @@ def get_languages():
|
|
|
|
|
|
def tess_base_args(langs: List[str], engine_mode: Optional[int]) -> List[str]:
|
|
- args = ['tesseract']
|
|
+ args = ['@tesseract@']
|
|
if langs:
|
|
args.extend(['-l', '+'.join(langs)])
|
|
if engine_mode is not None:
|
|
diff --git a/src/ocrmypdf/_exec/unpaper.py b/src/ocrmypdf/_exec/unpaper.py
|
|
index 479959ef..cc15fdec 100644
|
|
--- a/src/ocrmypdf/_exec/unpaper.py
|
|
+++ b/src/ocrmypdf/_exec/unpaper.py
|
|
@@ -69,7 +69,7 @@ class UnpaperImageTooLargeError(Exception):
|
|
|
|
|
|
def version() -> str:
|
|
- return get_version('unpaper')
|
|
+ return get_version('@unpaper@')
|
|
|
|
|
|
SUFFIXES = {'1': '.pbm', 'L': '.pgm', 'RGB': '.ppm'}
|
|
@@ -123,7 +123,7 @@ def _setup_unpaper_io(input_file: Path) -> Iterator[Tuple[Path, Path, Path]]:
|
|
def run_unpaper(
|
|
input_file: Path, output_file: Path, *, dpi: DecFloat, mode_args: List[str]
|
|
) -> None:
|
|
- args_unpaper = ['unpaper', '-v', '--dpi', str(round(dpi, 6))] + mode_args
|
|
+ args_unpaper = ['@unpaper@', '-v', '--dpi', str(round(dpi, 6))] + mode_args
|
|
|
|
with _setup_unpaper_io(input_file) as (input_pnm, output_pnm, tmpdir):
|
|
# To prevent any shenanigans from accepting arbitrary parameters in
|