# -*- 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 106537 2013-05-30 08:24:20Z deric@macports.org $

PortSystem          1.0
PortGroup           python 1.0

name                py-yaml
license             MIT
version             3.10
revision            2
categories-append   devel
platforms           darwin
maintainers         deric lightnin akitada openmaintainer

description         YAML 1.1 parser and emitter for Python
long_description    PyYAML is a YAML parser and emitter for Python, which \
                    supports YAML 1.1, unicode input and output, low-level \
                    event-based parser and emitter API, high-level API for \
                    serializing and deserializing native Python objects.

homepage            http://pyyaml.org/wiki/PyYAML
master_sites        http://pyyaml.org/download/pyyaml/
distname            PyYAML-${version}
checksums           md5     74c94a383886519e9e7b3dd1ee540247 \
                    sha1    476dcfbcc6f4ebf3c06186229e8e2bd7d7b20e73 \
                    rmd160  0fe20d93030c15b0ea6dcfc8dfee0f1f0d418aeb

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

livecheck.url http://pyyaml.org/download/pyyaml/
livecheck.regex PyYAML-(\[0-9+\]\.\[0-9\]+)\.tar\.gz

if {$subport != $name} {
    depends_lib-append  port:libyaml \
                        port:py${python.version}-cython
    patchfiles          patch-setup.py

    if { ${python.version} == 24 } {
        # 3.09 is last version of py-yaml that support Python 2.4
        version 3.09
        revision 1
        distname            PyYAML-${version}
        
        checksums           md5     f219af2361e87fdc5e85e95b84c11d87 \
                            sha1    6131d6a42bbd3e88d7efa3784d69395a136267be \
                            rmd160  b5a5228db448e9c9507682cb36f620596a4a234c
    }
    
    post-patch {
        reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/setup.py
    }

    post-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/share/doc/${subport}
        xinstall -m 755 -d ${destroot}${prefix}/share/doc/${subport}/examples
        xinstall -m 755 -d \
          ${destroot}${prefix}/share/doc/${subport}/examples/yaml-highlight
        xinstall -m 644 -W ${worksrcpath} LICENSE README \
          ${destroot}${prefix}/share/doc/${subport}
        xinstall -m 644 -W ${worksrcpath}/examples/yaml-highlight yaml_hl.cfg \
          yaml_hl.py \
          ${destroot}${prefix}/share/doc/${subport}/examples/yaml-highlight
    }
}
