# -*- 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.11.1
revision            0
categories          textproc

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

maintainers         {@akierig fastmail.de:akierig} openmaintainer

checksums           rmd160  a96f2529b3165e7fd55c5f98a51bb90df27d2cb2 \
                    sha256  838ab69e0ee0f04feea0d5861a17badecab6d3beaed0e29a97058eadda58cbb1 \
                    size    7015278

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"
