uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
101
pkgs/development/python-modules/ocrmypdf/default.nix
Normal file
101
pkgs/development/python-modules/ocrmypdf/default.nix
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
{ lib
|
||||
, buildPythonPackage
|
||||
, coloredlogs
|
||||
, fetchFromGitHub
|
||||
, ghostscript
|
||||
, img2pdf
|
||||
, importlib-metadata
|
||||
, importlib-resources
|
||||
, jbig2enc
|
||||
, pdfminer-six
|
||||
, pikepdf
|
||||
, pillow
|
||||
, pluggy
|
||||
, pngquant
|
||||
, pytest-xdist
|
||||
, pytestCheckHook
|
||||
, pythonOlder
|
||||
, reportlab
|
||||
, setuptools-scm
|
||||
, setuptools-scm-git-archive
|
||||
, substituteAll
|
||||
, tesseract4
|
||||
, tqdm
|
||||
, unpaper
|
||||
, installShellFiles
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "ocrmypdf";
|
||||
version = "13.4.7";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ocrmypdf";
|
||||
repo = "OCRmyPDF";
|
||||
rev = "v${version}";
|
||||
# The content of .git_archival.txt is substituted upon tarball creation,
|
||||
# which creates indeterminism if master no longer points to the tag.
|
||||
# See https://github.com/ocrmypdf/OCRmyPDF/issues/841
|
||||
postFetch = ''
|
||||
rm "$out/.git_archival.txt"
|
||||
'';
|
||||
hash = "sha256-jCfMCjh8MdH5K76iyJCgtkgPtpxnCxlXlzttTIzINPk=";
|
||||
};
|
||||
|
||||
SETUPTOOLS_SCM_PRETEND_VERSION = version;
|
||||
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./paths.patch;
|
||||
gs = "${lib.getBin ghostscript}/bin/gs";
|
||||
jbig2 = "${lib.getBin jbig2enc}/bin/jbig2";
|
||||
pngquant = "${lib.getBin pngquant}/bin/pngquant";
|
||||
tesseract = "${lib.getBin tesseract4}/bin/tesseract";
|
||||
unpaper = "${lib.getBin unpaper}/bin/unpaper";
|
||||
})
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools-scm-git-archive
|
||||
setuptools-scm
|
||||
installShellFiles
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
coloredlogs
|
||||
img2pdf
|
||||
pdfminer-six
|
||||
pikepdf
|
||||
pillow
|
||||
pluggy
|
||||
reportlab
|
||||
tqdm
|
||||
] ++ (lib.optionals (pythonOlder "3.8") [
|
||||
importlib-metadata
|
||||
]) ++ (lib.optionals (pythonOlder "3.9") [
|
||||
importlib-resources
|
||||
]);
|
||||
|
||||
checkInputs = [
|
||||
pytest-xdist
|
||||
pytestCheckHook
|
||||
];
|
||||
|
||||
pythonImportsCheck = [
|
||||
"ocrmypdf"
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
installShellCompletion --cmd ocrmypdf \
|
||||
--bash misc/completion/ocrmypdf.bash \
|
||||
--fish misc/completion/ocrmypdf.fish
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/ocrmypdf/OCRmyPDF";
|
||||
description = "Adds an OCR text layer to scanned PDF files, allowing them to be searched";
|
||||
license = with licenses; [ mpl20 mit ];
|
||||
maintainers = with maintainers; [ kiwi dotlambda ];
|
||||
changelog = "https://github.com/ocrmypdf/OCRmyPDF/blob/${src.rev}/docs/release_notes.rst";
|
||||
};
|
||||
}
|
||||
127
pkgs/development/python-modules/ocrmypdf/paths.patch
Normal file
127
pkgs/development/python-modules/ocrmypdf/paths.patch
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
diff --git a/src/ocrmypdf/_exec/ghostscript.py b/src/ocrmypdf/_exec/ghostscript.py
|
||||
index 1146cc5f..43f3915c 100644
|
||||
--- a/src/ocrmypdf/_exec/ghostscript.py
|
||||
+++ b/src/ocrmypdf/_exec/ghostscript.py
|
||||
@@ -40,15 +40,7 @@ For details see:
|
||||
# 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 a3688f65..61f54465 100644
|
||||
--- a/src/ocrmypdf/_exec/tesseract.py
|
||||
+++ b/src/ocrmypdf/_exec/tesseract.py
|
||||
@@ -75,7 +75,7 @@ class TesseractVersion(StrictVersion):
|
||||
|
||||
|
||||
def version() -> str:
|
||||
- return get_version('tesseract', regex=r'tesseract\s(.+)')
|
||||
+ return get_version('@tesseract@', regex=r'tesseract\s(.+)')
|
||||
|
||||
|
||||
def has_user_words():
|
||||
@@ -97,7 +97,7 @@ def get_languages():
|
||||
msg += output
|
||||
return msg
|
||||
|
||||
- args_tess = ['tesseract', '--list-langs']
|
||||
+ args_tess = ['@tesseract@', '--list-langs']
|
||||
try:
|
||||
proc = run(
|
||||
args_tess,
|
||||
@@ -119,7 +119,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 aec365c2..cc5cb7e4 100644
|
||||
--- a/src/ocrmypdf/_exec/unpaper.py
|
||||
+++ b/src/ocrmypdf/_exec/unpaper.py
|
||||
@@ -31,7 +31,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def version() -> str:
|
||||
- return get_version('unpaper')
|
||||
+ return get_version('@unpaper@')
|
||||
|
||||
|
||||
def _setup_unpaper_io(tmpdir: Path, input_file: Path) -> Tuple[Path, Path]:
|
||||
@@ -71,7 +71,7 @@ def _setup_unpaper_io(tmpdir: Path, input_file: Path) -> Tuple[Path, Path]:
|
||||
def run(
|
||||
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 TemporaryDirectory() as tmpdir:
|
||||
input_pnm, output_pnm = _setup_unpaper_io(Path(tmpdir), input_file)
|
||||
Loading…
Add table
Add a link
Reference in a new issue