Remove qpdf appimage support for now, check for pngquant
This commit is contained in:
@@ -185,13 +185,17 @@ if not forced and command.startswith('install') or \
|
||||
package='unpaper',
|
||||
optional=True
|
||||
)
|
||||
if not os.environ.get('OCRMYPDF_QPDF_APPIMAGE'):
|
||||
check_external_program(
|
||||
program='qpdf',
|
||||
need_version='7.0.0', # test suite known to fail on 5.1.1
|
||||
package='qpdf',
|
||||
version_check_args=['--version']
|
||||
)
|
||||
check_external_program(
|
||||
program='qpdf',
|
||||
need_version='8.0.2', # test suite known to fail on 5.1.1
|
||||
package='qpdf'
|
||||
)
|
||||
check_external_program(
|
||||
program='pngquant',
|
||||
need_version='2.0.0',
|
||||
package='pngquant',
|
||||
optional=True
|
||||
)
|
||||
|
||||
if 'upload' in sys.argv[1:]:
|
||||
print('Use twine to upload the package - setup.py upload is insecure')
|
||||
@@ -246,7 +250,7 @@ setup(
|
||||
'defusedxml >= 0.5.0', # pure Python, so track HEAD closely
|
||||
'img2pdf >= 0.2.4', # pure Python, so track HEAD closely
|
||||
'pikepdf',
|
||||
'Pillow >= 4.0.0, != 5.1.0 ; sys_platform == "darwin"',
|
||||
'Pillow >= 4.0.0, != 5.1.0 ; sys_platform == "darwin"',
|
||||
# Pillow < 4 has BytesIO/TIFF bug w/img2pdf 0.2.3
|
||||
# block 5.1.0, broken wheels
|
||||
'PyPDF2 >= 1.26', # pure Python, so track HEAD closely
|
||||
|
||||
@@ -30,8 +30,6 @@ from ..helpers import re_symlink
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def version():
|
||||
if 'OCRMYPDF_QPDF_APPIMAGE' in os.environ:
|
||||
return os.environ['OCRMYPDF_QPDF_APPIMAGE']
|
||||
return get_version('qpdf', regex=r'qpdf version (.+)')
|
||||
|
||||
|
||||
@@ -46,7 +44,7 @@ def check(input_file, log=None):
|
||||
import logging as log
|
||||
|
||||
try:
|
||||
run(args_qpdf, stderr=STDOUT, stdout=PIPE, universal_newlines=True,
|
||||
run(args_qpdf, stderr=STDOUT, stdout=PIPE, universal_newlines=True,
|
||||
check=True)
|
||||
except CalledProcessError as e:
|
||||
if e.returncode == 2:
|
||||
@@ -76,7 +74,7 @@ def repair(input_file, output_file, log):
|
||||
'qpdf', input_file, output_file
|
||||
]
|
||||
try:
|
||||
run(args_qpdf, stderr=STDOUT, stdout=PIPE, universal_newlines=True,
|
||||
run(args_qpdf, stderr=STDOUT, stdout=PIPE, universal_newlines=True,
|
||||
check=True)
|
||||
except CalledProcessError as e:
|
||||
if e.returncode == 3 and e.output.find("operation succeeded"):
|
||||
@@ -131,7 +129,7 @@ def extract_page(input_file, output_file, pageno):
|
||||
output_file
|
||||
]
|
||||
run(args_qpdf, check=True)
|
||||
|
||||
|
||||
|
||||
def _merge_inner(input_files, output_file, min_version=None, log=None):
|
||||
"""Merge the list of input files (all filenames) into the output file.
|
||||
@@ -173,10 +171,10 @@ def merge(input_files, output_file, min_version=None, log=None, max_files=None):
|
||||
The input files may contain one or more pages.
|
||||
|
||||
"""
|
||||
# qpdf requires that every file that contributes to the output has a file
|
||||
# descriptor that remains open. That means, given our approach of one
|
||||
# intermediate PDF per, we can practically hit the number of file
|
||||
# descriptors.
|
||||
# qpdf requires that every file that contributes to the output has a file
|
||||
# descriptor that remains open. That means, given our approach of one
|
||||
# intermediate PDF per, we can practically hit the number of file
|
||||
# descriptors.
|
||||
|
||||
if max_files is None or max_files < 2:
|
||||
# Find out how many open file descriptors we can get away with
|
||||
@@ -188,7 +186,7 @@ def merge(input_files, output_file, min_version=None, log=None, max_files=None):
|
||||
output_dir = os.path.dirname(output_file)
|
||||
|
||||
import random
|
||||
import string
|
||||
import string
|
||||
|
||||
def randstr():
|
||||
return ''.join(random.sample(string.ascii_lowercase, 6))
|
||||
@@ -212,7 +210,7 @@ def merge(input_files, output_file, min_version=None, log=None, max_files=None):
|
||||
counter += 1
|
||||
_merge_inner(job, merge_file, min_version=min_version, log=log)
|
||||
|
||||
# On the next
|
||||
# On the next
|
||||
next_workqueue.append(merge_file)
|
||||
log.debug('next_workqueue ' + repr(next_workqueue))
|
||||
|
||||
@@ -225,5 +223,3 @@ def merge(input_files, output_file, min_version=None, log=None, max_files=None):
|
||||
next_workqueue = []
|
||||
|
||||
re_symlink(workqueue.pop(), output_file, log)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user