Robert Schütz 2023-09-28 09:09:46 -07:00
parent 03d8585936
commit b1f18e30c9
2 changed files with 43 additions and 52 deletions

View file

@ -25,14 +25,15 @@
, tqdm , tqdm
, typing-extensions , typing-extensions
, unpaper , unpaper
, wheel
, installShellFiles , installShellFiles
}: }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "ocrmypdf"; pname = "ocrmypdf";
version = "14.4.0"; version = "15.0.1";
disabled = pythonOlder "3.8"; disabled = pythonOlder "3.9";
format = "pyproject"; format = "pyproject";
@ -46,7 +47,7 @@ buildPythonPackage rec {
postFetch = '' postFetch = ''
rm "$out/.git_archival.txt" rm "$out/.git_archival.txt"
''; '';
hash = "sha256-i1ZUBKR8dJXZkALUFwkzYcjtZ5Li66DfD2fupCGRQC4="; hash = "sha256-WTUe4ivSEU/4KMRtKhf1MDXN1segIe/wrXYVA5zJrZw=";
}; };
SETUPTOOLS_SCM_PRETEND_VERSION = version; SETUPTOOLS_SCM_PRETEND_VERSION = version;
@ -65,6 +66,7 @@ buildPythonPackage rec {
nativeBuildInputs = [ nativeBuildInputs = [
setuptools setuptools
setuptools-scm setuptools-scm
wheel
installShellFiles installShellFiles
]; ];
@ -78,9 +80,6 @@ buildPythonPackage rec {
pluggy pluggy
reportlab reportlab
rich rich
tqdm
] ++ lib.optionals (pythonOlder "3.9") [
importlib-resources
] ++ lib.optionals (pythonOlder "3.10") [ ] ++ lib.optionals (pythonOlder "3.10") [
typing-extensions typing-extensions
]; ];

View file

@ -1,69 +1,61 @@
diff --git a/src/ocrmypdf/_exec/ghostscript.py b/src/ocrmypdf/_exec/ghostscript.py diff --git a/src/ocrmypdf/_exec/ghostscript.py b/src/ocrmypdf/_exec/ghostscript.py
index 9e21c33c..21f134b3 100644 index e28d23e9..183cd918 100644
--- a/src/ocrmypdf/_exec/ghostscript.py --- a/src/ocrmypdf/_exec/ghostscript.py
+++ b/src/ocrmypdf/_exec/ghostscript.py +++ b/src/ocrmypdf/_exec/ghostscript.py
@@ -32,15 +32,7 @@ log = logging.getLogger(__name__) @@ -67,7 +67,7 @@ log.addFilter(DuplicateFilter(log))
# 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': # Ghostscript executable - gswin32c is not supported
- if _IS_64BIT: -GS = 'gswin64c' if os.name == 'nt' else 'gs'
- _GSWIN = 'gswin64c'
- else:
- _GSWIN = 'gswin32c'
-
-GS = _GSWIN if _GSWIN else 'gs'
-del _GSWIN
+GS = '@gs@' +GS = '@gs@'
def version(): def version() -> Version:
diff --git a/src/ocrmypdf/_exec/jbig2enc.py b/src/ocrmypdf/_exec/jbig2enc.py diff --git a/src/ocrmypdf/_exec/jbig2enc.py b/src/ocrmypdf/_exec/jbig2enc.py
index 0f8f7392..db792b10 100644 index 28d3dd1c..477a7d6c 100644
--- a/src/ocrmypdf/_exec/jbig2enc.py --- a/src/ocrmypdf/_exec/jbig2enc.py
+++ b/src/ocrmypdf/_exec/jbig2enc.py +++ b/src/ocrmypdf/_exec/jbig2enc.py
@@ -12,7 +12,7 @@ from ocrmypdf.subprocess import get_version, run @@ -14,7 +14,7 @@ from ocrmypdf.subprocess import get_version, run
def version(): def version() -> Version:
- return get_version('jbig2', regex=r'jbig2enc (\d+(\.\d+)*).*') - return Version(get_version('jbig2', regex=r'jbig2enc (\d+(\.\d+)*).*'))
+ return get_version('@jbig2@', regex=r'jbig2enc (\d+(\.\d+)*).*') + return Version(get_version('@jbig2@', regex=r'jbig2enc (\d+(\.\d+)*).*'))
def available(): def available():
@@ -25,7 +25,7 @@ def available(): @@ -27,7 +27,7 @@ def available():
def convert_group(*, cwd, infiles, out_prefix): def convert_group(*, cwd, infiles, out_prefix, threshold):
args = [ args = [
- 'jbig2', - 'jbig2',
+ '@jbig2@', + '@jbig2@',
'-b', '-b',
out_prefix, out_prefix,
'-s', # symbol mode (lossy) '--symbol-mode', # symbol mode (lossy)
@@ -44,7 +44,7 @@ def convert_group_mp(args): @@ -50,7 +50,7 @@ def convert_group_mp(args):
def convert_single(*, cwd, infile, outfile): def convert_single(*, cwd, infile, outfile, threshold):
- args = ['jbig2', '-p', infile] - args = ['jbig2', '--pdf', '-t', str(threshold), infile]
+ args = ['@jbig2@', '-p', infile] + args = ['@jbig2@', '--pdf', '-t', str(threshold), infile]
with open(outfile, 'wb') as fstdout: with open(outfile, 'wb') as fstdout:
proc = run(args, cwd=cwd, stdout=fstdout, stderr=PIPE) proc = run(args, cwd=cwd, stdout=fstdout, stderr=PIPE)
proc.check_returncode() proc.check_returncode()
diff --git a/src/ocrmypdf/_exec/pngquant.py b/src/ocrmypdf/_exec/pngquant.py diff --git a/src/ocrmypdf/_exec/pngquant.py b/src/ocrmypdf/_exec/pngquant.py
index 64e91139..ab5b9c49 100644 index 8425caec..a027f041 100644
--- a/src/ocrmypdf/_exec/pngquant.py --- a/src/ocrmypdf/_exec/pngquant.py
+++ b/src/ocrmypdf/_exec/pngquant.py +++ b/src/ocrmypdf/_exec/pngquant.py
@@ -17,7 +17,7 @@ from ocrmypdf.subprocess import get_version, run @@ -18,7 +18,7 @@ from ocrmypdf.subprocess import get_version, run
def version(): def version() -> Version:
- return get_version('pngquant', regex=r'(\d+(\.\d+)*).*') - return Version(get_version('pngquant', regex=r'(\d+(\.\d+)*).*'))
+ return get_version('@pngquant@', regex=r'(\d+(\.\d+)*).*') + return Version(get_version('@pngquant@', regex=r'(\d+(\.\d+)*).*'))
def available(): def available():
@@ -44,7 +44,7 @@ def input_as_png(input_file: Path): @@ -45,7 +45,7 @@ def input_as_png(input_file: Path):
def quantize(input_file: Path, output_file: Path, quality_min: int, quality_max: int): def quantize(input_file: Path, output_file: Path, quality_min: int, quality_max: int):
with input_as_png(input_file) as input_stream: with input_as_png(input_file) as input_stream:
args = [ args = [
@ -73,19 +65,19 @@ index 64e91139..ab5b9c49 100644
'--skip-if-larger', '--skip-if-larger',
'--quality', '--quality',
diff --git a/src/ocrmypdf/_exec/tesseract.py b/src/ocrmypdf/_exec/tesseract.py diff --git a/src/ocrmypdf/_exec/tesseract.py b/src/ocrmypdf/_exec/tesseract.py
index ad98836a..a12d3002 100644 index 4eac3470..61315d14 100644
--- a/src/ocrmypdf/_exec/tesseract.py --- a/src/ocrmypdf/_exec/tesseract.py
+++ b/src/ocrmypdf/_exec/tesseract.py +++ b/src/ocrmypdf/_exec/tesseract.py
@@ -111,7 +111,7 @@ class TesseractVersion(Version): @@ -114,7 +114,7 @@ class TesseractVersion(Version):
def version() -> str: def version() -> Version:
- return get_version('tesseract', regex=r'tesseract\s(.+)') - return TesseractVersion(get_version('tesseract', regex=r'tesseract\s(.+)'))
+ return get_version('@tesseract@', regex=r'tesseract\s(.+)') + return TesseractVersion(get_version('@tesseract@', regex=r'tesseract\s(.+)'))
def has_user_words() -> bool: def has_thresholding() -> bool:
@@ -138,7 +138,7 @@ def get_languages() -> set[str]: @@ -132,7 +132,7 @@ def get_languages() -> set[str]:
msg += output msg += output
return msg return msg
@ -94,7 +86,7 @@ index ad98836a..a12d3002 100644
try: try:
proc = run( proc = run(
args_tess, args_tess,
@@ -160,7 +160,7 @@ def get_languages() -> set[str]: @@ -154,7 +154,7 @@ def get_languages() -> set[str]:
def tess_base_args(langs: list[str], engine_mode: int | None) -> list[str]: def tess_base_args(langs: list[str], engine_mode: int | None) -> list[str]:
@ -104,19 +96,19 @@ index ad98836a..a12d3002 100644
args.extend(['-l', '+'.join(langs)]) args.extend(['-l', '+'.join(langs)])
if engine_mode is not None: if engine_mode is not None:
diff --git a/src/ocrmypdf/_exec/unpaper.py b/src/ocrmypdf/_exec/unpaper.py diff --git a/src/ocrmypdf/_exec/unpaper.py b/src/ocrmypdf/_exec/unpaper.py
index d7f24265..d14f85de 100644 index 2944b4f4..55a36140 100644
--- a/src/ocrmypdf/_exec/unpaper.py --- a/src/ocrmypdf/_exec/unpaper.py
+++ b/src/ocrmypdf/_exec/unpaper.py +++ b/src/ocrmypdf/_exec/unpaper.py
@@ -66,7 +66,7 @@ class UnpaperImageTooLargeError(Exception): @@ -69,7 +69,7 @@ class UnpaperImageTooLargeError(Exception):
def version() -> str: def version() -> Version:
- return get_version('unpaper') - return Version(get_version('unpaper'))
+ return get_version('@unpaper@') + return Version(get_version('@unpaper@'))
SUPPORTED_MODES = {'1', 'L', 'RGB'} SUPPORTED_MODES = {'1', 'L', 'RGB'}
@@ -120,7 +120,7 @@ def _setup_unpaper_io(input_file: Path) -> Iterator[tuple[Path, Path, Path]]: @@ -123,7 +123,7 @@ def _setup_unpaper_io(input_file: Path) -> Iterator[tuple[Path, Path, Path]]:
def run_unpaper( def run_unpaper(
input_file: Path, output_file: Path, *, dpi: DecFloat, mode_args: list[str] input_file: Path, output_file: Path, *, dpi: DecFloat, mode_args: list[str]
) -> None: ) -> None: