#-*- 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-pyside2
version                 5.15.19
revision                0

categories-append       devel aqua
maintainers             {pmetzger @pmetzger} {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description             Python bindings for the Qt cross-platform application and UI framework
long_description        {*}${description}
homepage                https://wiki.qt.io/Qt_for_Python
# see ${worksrcdir}/sources/pyside2/PySide2/licensecomment.txt
license                 {GPL-2 GPL-3+ LGPL-3}
master_sites            https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src
distname                pyside-setup-opensource-src-${version}
use_xz                  yes

checksums               rmd160  b94881c1d61c4b8d83f1c7164f89fef1ef5d3a53 \
                        sha256  c5640f5fc754522d4ac4b21af89d9922f7146fd32ab62d3494f58c7c7055d4c5 \
                        size    3586476

python.versions         310 311
python.pep517           no

set llvm_version        18

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

    # fix error with shiboken2 doc building
    patchfiles-append   patch-shiboken2-docs.diff

    # see https://trac.macports.org/ticket/68072
    qt5.min_version     5.14

    # Needed for generating shiboken2 documentation
    qt5.depends_build_component sqlite-plugin

    depends_build-append \
        path:bin/cmake:cmake \
        port:py${python.version}-setuptools \
        port:py${python.version}-sphinx \
        port:py${python.version}-wheel

    build.args-append \
        --verbose-build \
        --qmake=${qt_qmake_cmd} \
        --cmake=${prefix}/bin/cmake \
        --parallel=${build.jobs} \
        --macos-deployment-target=${macosx_deployment_target}

    if {${configure.sdkroot} != ""} {
        build.args-append \
            --macos-sysroot=${configure.sdkroot}
        # see https://trac.macports.org/ticket/57355
        build.env-append \
            SDKROOT=${configure.sdkroot}
    }

    destroot.args-append \
        --qmake=${qt_qmake_cmd} \
        --cmake=${prefix}/bin/cmake \
        --skip-cmake \
        --reuse-build

    depends_lib-append \
        port:libxml2 \
        port:libxslt \
        port:clang-${llvm_version} \
        port:llvm-${llvm_version} \
        port:py${python.version}-numpy

    # only find the llvm-config from the version we intend to
    patchfiles-append   patch-find-llvm-config.diff
    build.env-append    PATH=${prefix}/libexec/llvm-${llvm_version}/bin:$env(PATH)

    qt5.depends_component \
        qtxmlpatterns \
        qt3d \
        qtcharts \
        qtdatavis3d \
        qtdeclarative \
        qtgamepad \
        qtlocation \
        qtmacextras \
        qtmultimedia \
        qtquickcontrols2 \
        qtremoteobjects \
        qtscript \
        qtscxml \
        qtsensors \
        qtserialport \
        qtspeech \
        qtsvg \
        qttools \
        qtwebchannel \
        qtwebengine \
        qtwebsockets

    livecheck.type      none
} else {
    livecheck.type      regex
    livecheck.url       https://download.qt.io/official_releases/QtForPython/pyside2/
    livecheck.regex     (\\d+(\\.\\d+)+)
}
