# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           python 1.0

name                ocrmypdf
version             16.13.0
revision            0
categories          textproc

homepage            https://github.com/ocrmypdf/OCRmyPDF

maintainers         {@akierig fastmail.de:akierig} openmaintainer

checksums           rmd160  53189b364d9bb52dff01e36e3d89313900a2fd1c \
                    sha256  29d37e915234ce717374863a9cc5dd32d29e063dfe60c51380dda71254c88248 \
                    size    7042247

description         ${name} adds an OCR text layer to scanned PDF files, \
                    allowing them to be searched
long_description    {*}${description}. ${name} also supports plugins \
                    that enable customization of its processing steps, \
                    and it is highly tolerant of PDFs containing scanned \
                    images and “born digital” content that doesn’t require text recognition.

supported_archs     noarch
platforms           {darwin any}
license             MPL-2

set pyvers {310 311 312 313}
foreach pyver $pyvers {
    set pyconflicts [lmap v [ldelete $pyvers $pyver] {string cat python${v}}]
    variant python${pyver} conflicts {*}$pyconflicts description "Use Python 3.[string range $pyver 1 end]" {}
    if {[variant_isset python${pyver}]} {
        python.default_version  ${pyver}
        set any_py_variant_set 1
    }
}
if {![info exists any_py_variant_set]} {
    default_variants +python313
    python.default_version 313
}

python.pep517_backend   hatch

depends_build-append \
                    port:py${python.version}-hatch-vcs
                    
depends_lib-append  port:img2pdf \
                    port:libpng \
                    port:qpdf \
                    port:py${python.version}-deprecation \
                    port:py${python.version}-freetype \
                    port:py${python.version}-packaging \
                    port:py${python.version}-pdfminer \
                    port:py${python.version}-Pillow \
                    port:py${python.version}-pikepdf \
                    port:py${python.version}-pluggy \
                    port:py${python.version}-pybind11 \
                    port:py${python.version}-pyheif \
                    port:py${python.version}-rich

depends_run-append  port:ghostscript \
                    port:jbig2enc \
                    port:pngquant \
                    port:tesseract \
                    port:tesseract-eng \
                    port:unpaper

# Avoid rust on 10.7 and lower
if {${os.platform} eq "darwin" && ${os.subplatform} eq "macosx" && ${os.major} < 12} {
    depends_run-delete \
                    port:pngquant
}

notes "
English support is enabled by default.
To enable support for other languages you will need to install corresponding tesseract language ports.
e.g., to add German support:

    port install tesseract-deu"
