# -*- 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-pmw
version             2.0.0
revision            1
maintainers         nomaintainer
platforms           darwin
license             MIT

description         high-level compound widget toolkit
long_description    Pmw is a toolkit for building high-level compound widgets in Python using \
                    the Tkinter module.

homepage            http://pmw.sourceforge.net/
master_sites        sourceforge:pmw
distname            Pmw-${version}

patchfiles          patch-pmw2.diff
patch.pre_args      -p1

checksums           rmd160  2a76186192f13eb22c373b3e0e60ce65cba506fe \
                    sha256  2babb2855feaabeea1003c6908b61c9d39cff606d418685f0559952714c680bb

supported_archs     noarch

python.versions     27 34 35 36

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

    if {${python.version} == 27} {
        set pmw_folder Pmw_1_3_3
    } else {
        set pmw_folder Pmw_2_0_0
    }
    post-patch {
        reinplace "s|format|fmt|g" ${worksrcpath}/Pmw/${pmw_folder}/demos/Counter.py
        system  -W ${worksrcpath} "/usr/bin/find . -type f -name '*.py' -print0 | xargs -0 perl -pi -e 's|/usr/bin/env python|${prefix}/bin/python${python.branch}|g'"
    }

    post-destroot {
        file attributes ${destroot}${python.pkgd}/Pmw/${pmw_folder}/demos/All.py -permissions +x
        file attributes ${destroot}${python.pkgd}/Pmw/${pmw_folder}/tests/All.py -permissions +x
        reinplace "s|\r||g" \
            ${destroot}${python.pkgd}/Pmw/${pmw_folder}/demos/All.py \
            ${destroot}${python.pkgd}/Pmw/${pmw_folder}/tests/All.py
    }

    livecheck.type      none
} else {
    livecheck.regex     Pmw-(\[0-9.\]+)${extract.suffix}
}