# -*- 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            3

supported_archs     noarch
platforms           {darwin any}
license             MIT
maintainers         nomaintainer

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}

checksums           rmd160  2a76186192f13eb22c373b3e0e60ce65cba506fe \
                    sha256  2babb2855feaabeea1003c6908b61c9d39cff606d418685f0559952714c680bb \
                    size    804092

python.versions     310

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

    patchfiles      patch-pmw2.diff \
                    patch-pmw2-py36.diff \
                    patch-callable.diff
    patch.pre_args-replace  -p0 -p1

    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
    }
} else {
    livecheck.regex     Pmw-(\[0-9.\]+)${extract.suffix}
}
