# -*- 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-yaml
python.rootname     pyyaml
version             6.0.3
revision            0
categories-append   devel
license             MIT

python.versions     27 310 311 312 313 314

maintainers         {stromnov @stromnov} 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            https://github.com/yaml/pyyaml

checksums           rmd160  78ac6dca7ad30103245e6d23d11d53d8512dd8d2 \
                    sha256  d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f \
                    size    130960

if {${name} ne ${subport}} {
    if {${python.version} == 27} {
        depends_build-append \
                            port:py${python.version}-cython-compat
        set compat_path [string replace ${python.pkgd} 0 [string length ${python.prefix}]-1 ${prefix}/lib/py${python.version}-cython-compat]
        build.env-append    PYTHONPATH=${compat_path}
        python.rootname     PyYAML
    } else {
        depends_build-append \
                            port:py${python.version}-cython
    }

    depends_lib-append  port:libyaml

    if {${python.version} == 27} {
        version             5.4.1
        revision            0
        checksums           rmd160  0f52f8f5ad2d5b516ef15955389da9d8aee1d9d9 \
                            sha256  607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e \
                            size    175147
    }

    patchfiles-append       patch-setup.py

    post-patch {
        reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/setup.py
    }

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

    livecheck.type      none
}
