# -*- 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 1.9.0 v
revision            1
name                py-qtpy

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

description         Abstraction layer for PyQt5/PyQt4/PySide2/PySide
long_description    QtPy (pronounced 'cutie pie') is a small abstraction layer \
                    that lets you write applications using a single API call \
                    to either PyQt or PySide. \
                    It provides support for PyQt5, PyQt4, PySide2 and PySide \
                    using the Qt5 layout (where the QtGui module has been split \
                    into QtGui and QtWidgets).

checksums           rmd160  2c557686126864e9f0ea150ff0769a7744f91928 \
                    sha256  436cffcd843a51703ee69e3c800aa471e0b887e491b3612ae6fd3ffeaa940fd2 \
                    size    35576

python.versions     27 35 36 37 38 39

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

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

    test.run        yes
    test.cmd        py.test-${python.branch}
    test.target
    test.env        PYTHONPATH=${worksrcpath}/build/lib

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

    livecheck.type  none

    notes "QtPy needs one of the following backends to be installed on your\
        system: PyQt5, PyQt4,PySide2, or Pyside. 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}-pyqt4] 0]}] &&
        [catch {set installed [lindex [registry_active py${python.version}-pyside2] 0]}] &&
        [catch {set installed [lindex [registry_active py${python.version}-pyside] 0]}] } {
            test.run        no
            notes-append    "*** WARNING: currently none of the required backends is installed! ***"
        }
}
