# -*- 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
PortGroup           qt6 1.0

name                py-pyside6
revision            0
categories-append   devel aqua

maintainers         {@johankytt gmail.com:johan.kytt} openmaintainer
license             LGPL
supported_archs     arm64 x86_64

python.pep517       no
universal_variant   no
use_xz              yes

description         Python bindings for the Qt cross-platform application and UI framework
long_description    PySide6 is the official Python module from the Qt for Python project, \
                    which provides access to the complete Qt 6.0+ framework.\
                    \nBy default, installs both the essential and addon modules. \
                    See https://doc.qt.io/qtforpython-6/package_details.html
homepage            https://pyside.org/

# Qt 6.8 is not supported on MacOS 13 (Darwin 22)
if {[vercmp ${qt6.version} 6.8] >= 0} {
    version 6.9.0
    checksums           rmd160  a93de1f959f333e4b7af85e09e87000a8e079e46 \
                        sha256  315b73bb7570d5b9e6793a8d3fafd1d2dd7f43d35eebb01d2b554ea206aad88e \
                        size    16652756

    python.versions     310 311 312 313
    set clang_version   19
    # Same clang version as for qt6-qtbase
} else {
    version             6.7.3
    checksums           rmd160  38dea392d656b16f4c0ad6b8e0971740f2080805 \
                        sha256  a4c414be013d5051a2d10a9a1151e686488a3172c08a57461ea04b0a0ab74e09 \
                        size    14591496

    python.versions     39 310 311 312
    set clang_version   18
}

distname            pyside-setup-everywhere-src-${version}
master_sites        https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-${version}-src

if {${name} ne ${subport}} {
    depends_lib-append \
        port:py${python.version}-numpy

    depends_build-append \
        path:bin/cmake:cmake \
        path:bin/ninja:ninja \
        port:clang-${clang_version} \
        port:py${python.version}-packaging \
        port:py${python.version}-setuptools

    build.args-append \
        --qtpaths=${prefix}/libexec/qt6/bin/qtpaths6 \
        --cmake=${prefix}/bin/cmake \
        --parallel=${build.jobs}

    build.env-append \
        LLVM_INSTALL_DIR=${prefix}/libexec/llvm-${clang_version}

    if {${configure.sdkroot} != ""} {
        build.args-append \
            --macos-sysroot=${configure.sdkroot}
    }

    destroot.args-append \
        --qtpaths=${prefix}/libexec/qt6/bin/qtpaths6 \
        --cmake=${prefix}/bin/cmake \
        --skip-cmake \
        --reuse-build

    qt6.depends_lib-append \
        qttools \
        qtlocation \
        qtsensors \
        qtconnectivity \
        qtserialbus \
        qt3d \
        qtwebview \
        qtcharts \
        qtdatavis3d \
        qtvirtualkeyboard \
        qtscxml \
        qtspeech \
        qtnetworkauth \
        qtremoteobjects \
        qtquicktimeline \
        qtquick3dphysics \
        qthttpserver \
        qtquickeffectmaker \
        qtgraphs

    variant essentialsonly description "Installs only the essential modules. See https://doc.qt.io/qtforpython-6/package_details.html" {
        set essential_modules "Core,Gui,Widgets,Help,Network,Concurrent,DBus,Designer,OpenGL,OpenGLWidgets,PrintSupport,Qml,Quick,QuickControls2,QuickTest,QuickWidgets,Xml,Test,Sql,Svg,SvgWidgets,UiTools"

        build.args-append \
            --module-subset=${essential_modules}
        destroot.args-append \
            --module-subset=${essential_modules}

        qt6.depends_lib \
            qttools
    }

    variant qtlottie description "Install the Qt Lottie Animation module used with the Bodymovin plugin for Adobe After Effects" {
        qt6.depends_lib-append \
            qtlottie
    }

    variant qt5compat description "Install the Qt5Compat module" {
        qt6.depends_lib-append \
            qt5compat
    }

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