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

name                py-msgpack

# Note that borgbackup has an in-code check that starts failing when msgpack is
# updated to a version it does not allowlist yet. We have removed this check
# downstream, but to avoid breaking our users' backups, please run `sudo port
# test borgbackup` with an updated msgpack before committing. Thanks!
version             1.1.1
revision            0
categories-append   devel
license             Apache-2

python.versions     27 39 310 311 312 313 314

maintainers         {stromnov @stromnov} openmaintainer

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

homepage            https://msgpack.org/

checksums           rmd160  f097a6b597b3c56a525485dfb6106f2bc232c195 \
                    sha256  77b79ce34a2bdab2594f490c8e80dd62a02d650b91a75159a63ec413b8d104cd \
                    size    173555

if {${name} ne ${subport}} {
    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
    }

    livecheck.type      none
}
