# -*- 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           select 1.0

# When updating, make sure py-librt is up-to-date.
# Since 2.x, every version MUST be fixed and confirmed to run on PowerPC, see below.
name                py-mypy
version             2.1.0
revision            0
license             MIT
maintainers         {toby @tobypeterson} openmaintainer
description         Optional static typing for Python
long_description    Add type annotations to your Python programs, and use mypy to \
                    type check them. Mypy is essentially a Python linter on steroids, \
                    and it can catch many programming errors by analyzing your \
                    program, without actually having to run it. Mypy has a powerful \
                    type system with features such as type inference, gradual typing, \
                    generics and union types.

homepage            https://www.mypy-lang.org

checksums           rmd160  9fa2bd7b60ea9b70742aefa4756c9f031e8832b1 \
                    sha256  81e76ad12c2d804512e9b13240d1588316531bfba07558286078bfbce9613633 \
                    size    3898359

python.versions     310 311 312 313 314

if {${subport} ne ${name}} {
    depends_build-append    port:py${python.version}-types-psutil \
                            port:py${python.version}-types-setuptools
    depends_lib-append      port:py${python.version}-librt \
                            port:py${python.version}-mypy_extensions \
                            port:py${python.version}-pathspec \
                            port:py${python.version}-typing_extensions
    depends_run-append      port:mypy_select

    if {${python.version} < 311} {
        depends_lib-append  port:py${python.version}-tomli
    }

    # FIXME
    # Unfortunarely, 2.x are stuck in the permanent regression in portability:
    # https://github.com/python/mypy/issues/21492
    # It is likely we will need to maintain a fork to keep fixing what upstream breaks.
    # Or otherwise peg mypy to the last working version.
    patchfiles-append       no-rusty-stuff.patch

    compiler.blacklist-append \
                            {clang < 602}

    compiler.c_standard     2011

    build.env-append        MYPY_USE_MYPYC=1

    # https://trac.macports.org/ticket/68943
    # https://github.com/python/mypy/issues/16684
    # https://github.com/python/mypy/issues/11507
    # https://github.com/iains/darwin-xtools/issues/18
    if {${configure.build_arch} ne "x86_64"} {
        build.env-append    MYPYC_DEBUG_LEVEL=0 \
                            MYPYC_MULTI_FILE=1
    }

    select.group            mypy
    select.file             ${filespath}/mypy${python.version}
}
