# -*- 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           github 1.0

github.setup        spyder-ide qtpy 2.4.3 v
github.tarball_from archive
revision            0
name                py-qtpy

categories-append   devel
supported_archs     noarch
platforms           {darwin any}
license             MIT
maintainers         {reneeotten @reneeotten} openmaintainer

description         Abstraction layer for PyQt5/PyQt6/PySide2/PySide6
long_description    Provides an uniform layer to support PyQt5, PyQt6, \
                    PySide2, and PySide6 with a single codebase.

checksums           rmd160  3a81f872f1756088f232c999a2f6a7bc54aa7ddb \
                    sha256  f5885e74adacc5b39a2da5f568d313d1770c6aa5c51b241c10e8d0233e23df15 \
                    size    69459

python.versions     39 310 311 312 313

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

    depends_test-append \
                    port:py${python.version}-pytest-qt

    test.run        yes

    post-destroot {
        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} LICENSE.txt ${destroot}${docdir}
    }

    notes "QtPy needs one of the following backends to be installed on your\
        system: PyQt5, PyQt6, PySide2, or PySide6. If multiple backends are\
        available, PyQt5 will be used unless you set the QT_API environment variable."

    # if no backend is installed, it is impossible to run the tests
    # also append a warning about this to the notes
    if {[catch {set installed [lindex [registry_active py${python.version}-pyqt5] 0]}] &&
        [catch {set installed [lindex [registry_active py${python.version}-pyqt6] 0]}] &&
        [catch {set installed [lindex [registry_active py${python.version}-pyside2] 0]}] &&
        [catch {set installed [lindex [registry_active py${python.version}-pyside6] 0]}]} {
            test.run        no
            notes-append    "*** WARNING: currently none of the required backends is installed! ***"
        }
}
