# -*- 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-pyqt5
version                 5.10.1
revision                0
categories-append       devel
platforms               darwin
maintainers             {mmoll @mamoll} openmaintainer
description             PyQt5 is a set of Python bindings for the Qt5 toolkit
long_description        ${description}. The bindings \
                        are implemented as a set of Python modules and contain over 620 classes.
homepage                http://www.riverbankcomputing.co.uk/software/pyqt/intro
license                 GPL-3
master_sites            sourceforge:pyqt
distname                PyQt5_gpl-${version}
checksums           rmd160  4e0d454172288d26d40ebf2c15a70e0e271da57e \
                    sha256  9932e971e825ece4ea08f84ad95017837fa8f3f29c6b0496985fa1093661e9ef \
                    size    3110469

python.versions 27 34 35 36

if {${os.major} <= 14 && ${os.platform} eq "darwin"} {
    version         5.9.2
    revision        1
    distname        PyQt5_gpl-${version}
    checksums       rmd160  744f54000240c25ce2b39dbe62f5b3d2afd83e8b \
                    sha256  c190dac598c97b0113ca5e7a37c71c623f02d1d713088addfacac4acfa4b8394 \
                    size    3102848
}

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

    # pull in the Qt5 meta-port
    qt5.depends_component \
                        qtscript \
                        qt3d \
                        qt5
    depends_lib-append  port:py${python.version}-sip \
                        port:dbus-python${python.version}

    use_configure       yes
    configure.pre_args
    configure.cmd       "${python.bin} configure.py"
    qt5.spec_cmd        --spec=
    configure.args-append \
                        -q ${qt_qmake_cmd} \
                        --verbose \
                        --confirm-license \
                        --sip=${prefix}/bin/sip-${python.branch} \
                        --dbus=${python.include}/dbus-1.0 \
                        --designer-plugindir=${qt_plugins_dir}/designer/Py${python.version}Qt5 \
                        --qml-plugindir=${qt_plugins_dir}/Py${python.version}Qt5 \
                        --no-qsci-api \
                        --disable=QtWebKit \
                        --disable=QtWebKitWidgets \
                        --disable=QtWebEngine \
                        --disable=QtWebEngineCore \
                        --disable=QtWebEngineWidgets

    # using --dbus means the compiler will find dbus-python.h but not
    # the DBus headers themselves
    # do not clear include directories just because --dbus is given
    patchfiles-append patch-dbus_includes.diff

    build.cmd           make
    build.target        all
    destroot.cmd        ${build.cmd}
    destroot.destdir    DESTDIR=${destroot}

    variant debug description "Build debug libraries" {
        configure.cmd-append --debug
    }

    variant scintilla description {Build the PyQt API for QScintilla} {
        depends_lib-append \
                        port:qscintilla-qt5
        configure.args-replace \
                        --no-qsci-api \
                        --qsci-api

        post-destroot {
            # move the Qsci API file to a Python specific name
            move ${destroot}${qt_data_dir}/qsci/api/python/PyQt5.api \
                ${destroot}${qt_data_dir}/qsci/api/python/PyQt5-Python${python.branch}.api
        }
    }

    variant webengine conflicts universal description {Build QtWebEngine module} {
        qt5.depends_component qtwebengine
        configure.args-delete --disable=QtWebEngine \
                              --disable=QtWebEngineCore \
                              --disable=QtWebEngineWidgets
    }

    variant webkit description {Build QtWebKit module} {
        qt5.depends_component qtwebkit
        configure.args-delete --disable=QtWebKit \
                              --disable=QtWebKitWidgets
    }

    variant graceful description {Don't abort (crash) on Python errors} {
        patchfiles-append  patch-no-abort-on-python-errors.diff
    }

    livecheck.type     none
} else {
    livecheck.type     regex
    livecheck.url      http://pyqt.sourceforge.net/Docs/PyQt5/introduction.html
    livecheck.regex    PyQt5 (5.\[0-9\]+(.\[0-9\]+)?)
}