# -*- 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                py-poppler-qt5
python.rootname     python-poppler-qt5
version             21.3.0
revision            1

platforms           darwin
license             LGPL-2.1+
maintainers         {gmail.com:davide.liessi @dliessi} openmaintainer

description         Python binding for Poppler-Qt5
long_description    ${python.rootname} is a Python binding for Poppler-Qt5 \
                    that aims for completeness \
                    and for being actively maintained. \
                    Using this module you can access \
                    the contents of PDF files \
                    inside PyQt5 applications.

homepage            https://github.com/wbsoft/${python.rootname}

checksums           md5     99c72b0a2043dfc7d5b92e0f167be4b2 \
                    rmd160  dc79ca00ae22256b8ea4ad035a8193a28721f804 \
                    sha256  b477e8841f0ea0e09fdab6f2f305cf38df977d9e142e5693a374605d75dd6fe0 \
                    size    28586

python.versions     39 310 311

compiler.cxx_standard   2017

if {${name} ne ${subport}} {
    if { ${os.platform} eq "darwin" && (( ${os.major} >= 15 && ${os.major} <= 16 ) || ${os.major} >= 20 ) } {
        use_xcode   yes
    }

    PortGroup       qmake5 1.0

    # see https://trac.macports.org/ticket/68764
    python.pep517   no

    # see https://trac.macports.org/ticket/68287
    patchfiles-append force-cxx17.diff

    depends_build-append \
                    port:py${python.version}-pyqt-builder

    depends_lib-append \
                    path:${python.prefix}/bin/sip-build:py${python.version}-sip

    build.cmd       sip-build-${python.branch}
    build.args-append \
                    --qmake ${qt_qmake_cmd} \
                    --verbose
    build.target

    pre-destroot {
        reinplace "s|sip-distinfo|sip-distinfo-${python.branch}|g" \
            ${build.dir}/build/Makefile
    }

    destroot.cmd    make
    destroot.dir    ${build.dir}/build

    depends_build-append \
                    port:py${python.version}-setuptools

    depends_lib-append \
                    port:poppler-qt5 \
                    port:py${python.version}-pyqt5

    post-destroot {
        set doc_dir ${destroot}${prefix}/share/doc/${subport}
        xinstall -d ${doc_dir}
        xinstall -m 0644 -W ${worksrcpath} \
            ChangeLog LICENSE README.rst \
            ${doc_dir}

        set examples_dir ${destroot}${prefix}/share/examples/${subport}
        xinstall -d ${examples_dir}
        xinstall -m 0644 -W ${worksrcpath}/demo \
            demo.py merge-annotations.py \
            ${examples_dir}
    }

    livecheck.type  none
}
