# -*- 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           compiler_wrapper 1.0
PortGroup           python 1.0

name                py-msgpack
version             1.2.1
revision            0
categories-append   devel
license             Apache-2

python.versions     27 310 311 312 313 314

maintainers         {stromnov @stromnov} openmaintainer

description         MessagePack (de)serializer for Python.
long_description    {*}${description}

homepage            https://msgpack.org

checksums           rmd160  c17304037ae95a59f87c03589bb002364831b84c \
                    sha256  04c721c2c7448767e9e3f2520a475663d8ee0f09c31890f6d2bd70fd636a9647 \
                    size    183960

if {${subport} ne ${name}} {
    depends_build-append \
                        port:py${python.version}-cython

    # https://trac.macports.org/ticket/69537
    if {${configure.build_arch} in [list i386 ppc]} {
        patchfiles-append \
                        patch-32-bit.diff
    }

    if {${python.version} <= 37} {
        version             1.0.5
        revision            1
        checksums           rmd160  44d092ee572b7cb3ac8555e2224a412a61f2e08e \
                            sha256  c075544284eadc5cddc70f4757331d99dcbc16b2bbd4849d15f8aae4cf36d31c \
                            size    127834

        depends_build-delete \
                            port:py${python.version}-cython

        if {${python.version} eq 27} {
            platforms           any
            supported_archs     noarch
            python.pep517       no
            depends_build-append \
                                port:py${python.version}-setuptools
        } else {
            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}
        }
    }

    if {${python.version} ne 27} {
        # make sure that the files are cythonized
        post-extract {
            file delete ${worksrcpath}/msgpack/_cmsgpack.cpp
        }
    }

    # https://trac.macports.org/ticket/71250
    if {${python.version} >= 312} {
        compiler.blacklist-append \
                        *gcc-4.0 *gcc-4.2
    } else {
        if {[string match *gcc-4.* ${configure.compiler}]} {
            # msgpack/_cmsgpack.c: error: ‘for’ loop initial declaration used outside C99 mode
            build.cmd-prepend \
                        CFLAGS="-std=c99"
        }
    }

    livecheck.type      none
}
