# -*- 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-pyqt5
python.rootname     PyQt5
version             5.15.11
revision            0

categories-append   devel
license             {GPL-3 OpenSSLException}
maintainers         {reneeotten @reneeotten} openmaintainer

description         PyQt5 is a set of Python bindings for the Qt5 toolkit
long_description    {*}${description}. The bindings are implemented as a set of Python modules and contain over 620 classes.

homepage            https://www.riverbankcomputing.com/software/pyqt/intro

checksums           rmd160  a1e985ed3c2ecb7dc919ce326c80669bbe6633ab \
                    sha256  fda45743ebb4a27b4b1a51c6d8ef455c4c1b5d610c90d2934c7802b5c1557c52 \
                    size    3216775

python.versions     39 310 311 312 313 314

supported_archs     arm64 x86_64

if {${name} ne ${subport}} {
    PortGroup       qmake5 1.0

    python.pep517   no

    # https://trac.macports.org/ticket/65410
    if { ${os.platform} eq "darwin" && (( ${os.major} >= 15 && ${os.major} <= 16 ) || ${os.major} >= 20 ) } {
        use_xcode   yes
    }

    patchfiles      patch-project.py.diff

    post-patch {
        reinplace "s|@PYVER@|${python.version}|g" ${worksrcpath}/project.py
    }

    compiler.cxx_standard 2011

    qt5.min_version 5.6
    qt5.depends_component \
                    qtscript \
                    qt3d \
                    qt5

    depends_build-append \
                    port:py${python.version}-pyqt-builder \
                    path:${python.prefix}/bin/sip-build:py${python.version}-sip

    depends_lib-append \
                    port:dbus-python${python.version}

    depends_run-append \
                    port:py${python.version}-pyqt5-sip

    build.args-append \
                    --qmake ${qt_qmake_cmd} \
                    --verbose \
                    --confirm-license \
                    --dbus=${python.include}/dbus-1.0 \
                    --disable QtWebKit \
                    --disable QtWebKitWidgets

    build.cmd       sip-build-${python.branch}
    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

    variant webkit description {Build QtWebKit module} {
        qt5.depends_component   qtwebkit
        build.args-delete       --disable QtWebKit \
                                --disable QtWebKitWidgets
    }

    variant debug description "Build debug libraries" {
        build.cmd-append    --debug
    }
}
