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

python.versions     27 35 36 37 38 39 310 311 312

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  d7d944c9be55413d0a7431669a274cd1e579dd13 \
                    sha256  bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43 \
                    size    125201

if {${name} ne ${subport}} {
    # Not compatible with Cython 3 as of 6.0.1
    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}

    depends_lib-append  port:libyaml

    if {${python.version} < 37} {
        version             5.4.1
        revision            0
        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
}
