#-*- 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.18
revision                1
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  a2048b312b679d8885355a212396d046f4e2a036 \
                        sha256  aa13963698991589fdec4f19735c6fd7200b7544ba521d64a69e2cea365fd98b \
                        size    3586736

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+)+)
}
