# -*- 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
# $Id: Portfile 92505 2012-04-30 13:40:42Z jmr@macports.org $

PortSystem              1.0
PortGroup               python 1.0
PortGroup               select 1.0

name                    py-bpython
version                 0.10.1
platforms               darwin
categories              python 
maintainers             singingwolfboy openmaintainer
description             fancy interface to the Python interpreter
long_description        a fancy interface to the Python interpreter for \
                        Unix-like operating systems

homepage                http://www.bpython-interpreter.org/
master_sites            ${homepage}/releases/
distname                bpython-${version}
checksums               rmd160  4a62158fce1e86c906900913e10c342820936050 \
                        sha256  73546a3162ddd9da400ded365c65393989221397da54690e4d25f1ddef3dbc16

python.versions         25 26 27 31 32
python.default_version  27

subport py25-bpython {
    python.link_binaries    no
    python.link_binaries_suffix "-2.5"
    post-destroot {
        foreach bin [glob -nocomplain -tails -directory "${destroot}${prefix}/bin" *] {
            if {[catch {file type "${destroot}${prefix}/bin/${bin}${python.link_binaries_suffix}"}]} {
                move "${destroot}${prefix}/bin/${bin}" "${destroot}${prefix}/bin/${bin}${python.link_binaries_suffix}"
            }
        }
    }
}


if {$name != $subport} {
    depends_lib-append      port:py${python.version}-parsing \
                            port:py${python.version}-pygments \
                            port:py${python.version}-distribute

    select.group            bpython
    select.file             ${filespath}/bpython${python.version}
    
    post-destroot {
        if {${python.branch} == "2.5"} {
            set pyetc ${destroot}${prefix}/share/${subport}/etc
            xinstall -d ${pyetc}
            set themedir ${destroot}${prefix}/share/${subport}/themes
            xinstall -d ${themedir}

            set mandir ${destroot}${prefix}/share/${subport}/man
            xinstall -d ${mandir}/man1 ${mandir}/man5
            xinstall ${worksrcpath}/doc/bpython.1 ${mandir}/man1
            xinstall ${worksrcpath}/doc/bpython-config.5 ${mandir}/man5
        } else {
            set pyetc ${destroot}${python.prefix}/etc
            xinstall -d ${pyetc}
            set themedir ${destroot}${python.prefix}/share/themes
            xinstall -d ${themedir}
            set mandir ${destroot}${prefix}/share/${subport}/man
        }

        xinstall -W ${worksrcpath} sample-config ${pyetc}
        xinstall -W ${worksrcpath} sample.theme light.theme \
            ${themedir}
    }                        
}
