# -*- coding: utf-8; mode: tcl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=2:ts=2:sts=2

PortSystem          1.0
PortGroup           python      1.0
PortGroup           wxWidgets   1.0

name                py-wxpython-3.0
version             3.0.2.0
set wx_version      [join [lrange [split ${version} .] 0 2] .]
set branch          [join [lrange [split ${version} .] 0 1] .]
categories-append   graphics devel
license             wxwidgets-3.1
platforms           darwin
maintainers         nomaintainer

description         Python interface to the wxWidgets ${branch} cross platform GUI
long_description    wxPython is a GUI toolkit for the Python programming \
                    language. It allows Python programmers to create \
                    programs with a robust, highly functional graphical \
                    user interface, simply and easily. It is implemented \
                    as a Python extension module (native code) that wraps \
                    the wxWidgets cross platform GUI library, written in C++.

homepage            http://www.wxpython.org/
master_sites        sourceforge:wxpython

distname            wxPython
use_bzip2           yes

checksums           rmd160  6ae920a192f482ec92de8539c8f957e1f427f9c4 \
                    sha256  d54129e5fbea4fb8091c87b2980760b72c22a386cb3b9dd2eebc928ef5e8df61 \
                    size    58304944

python.versions     27
python.default_version 27

distfiles           ${distname}-src-${version}${extract.suffix}
worksrcdir          ${distname}-src-${version}/wxPython
dist_subdir         wxWidgets/${wx_version}

# extract just the docs and wxPython subdir
extract.post_args   "| tar -xf - ${worksrcdir} ${distname}-src-${version}/docs"

if {${name} ne ${subport}} {
    # As long as wxPython and wxWidgets are at the same version,
    # this port could also depend on wxWidgets-3.0.
    # A separate port is there just because wxPython usually lags behind.
    wxWidgets.use   wxPython-3.0
    depends_lib-append \
                    port:${wxWidgets.port}

    patchfiles      patch-config.py.diff

    # TODO: is it possible to use build arguments instead of redefining the whole command?
    build.cmd       ${python.bin} setup.py WX_CONFIG="${wxWidgets.wxconfig}"
    destroot.cmd    ${python.bin} setup.py WX_CONFIG="${wxWidgets.wxconfig}"

    post-destroot {
        # When a new release of wxPython comes out, the contents of
        # ${destroot}${wxWidgets.prefix}/Versions/wxPython/${branch}/include/wx-${branch}/wx/wxPython
        # should be stored separately into wxPython-${version}-MacPorts-subset.tar.bz2
        # to be extracted/installed by wxPython-3.0 rather than this port.
        # This allows parallel installation of several versions of py**-wxpython-3.0.
        delete      ${destroot}${wxWidgets.prefix}
    }

    livecheck.type  none
} else {
    # Once upon a time this would install the documentation,
    # however the python PortGroup disables all steps including fetching & extracting
    # which makes it a bit inconvenient to do things like this.
    # If anyone is missing the docs badly enough, you are welcome to fix this.
    #
    # post-destroot {
    #     xinstall -d -m 755 ${destroot}${prefix}/share/doc/
    #     file copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${name}
    #     file copy ${worksrcpath}/samples ${destroot}${prefix}/share/doc/${name}/examples
    # }

    livecheck.url   https://api.github.com/repos/wxWidgets/wxPython/tags
    livecheck.regex tarball/wxPy-(3\\.0\\.\[^"\]+)
}
