# -*- 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.2
revision            0
categories-append   devel
license             MIT

python.versions     27 37 38 39 310 311 312 313

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  037cdf77e11f753a865c49f0f746a8fb41d5e02a \
                    sha256  d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e \
                    size    130631

if {${name} ne ${subport}} {
    if {${python.version} < 313} {
        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}
    } else {
        depends_build-append \
                            port:py${python.version}-cython
    }

    depends_lib-append  port:libyaml

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

    patchfiles          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
}
