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

github.setup        mitmproxy mitmproxy 11.0.2 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0

name                py-${github.project}

categories-append   net www
platforms           {darwin any}
supported_archs     noarch
license             {MIT}
maintainers         {petr @petrrr} openmaintainer

description         SSL/TLS-capable man-in-the-middle proxy for HTTP and Websockets
long_description    \
    mitmproxy is an SSL/TLS-capable man-in-the-middle proxy for HTTP/1, HTTP/2 \
    and Websockets. It provides a console interface that allows traffic flows \
    to be inspected and edited on the fly. mitmdump is the command-line version \
    of mitmproxy, with the same functionality but without the user interface. \
    Think tcpdump for HTTP.

homepage            https://mitmproxy.org/

checksums           rmd160  74c695393f3aaab519fa268d0720936092424473 \
                    sha256  2e67521b00970997f101c15a598d17ad0440411d1cd2c978879791c73e4251ce \
                    size    31029542

python.versions     310 311 312 313

if {${name} ne ${subport}} {
    depends_lib-append      port:py${python.version}-aioquic \
                            port:py${python.version}-asgiref \
                            port:py${python.version}-brotli \
                            port:py${python.version}-certifi \
                            port:py${python.version}-cryptography \
                            port:py${python.version}-flask \
                            port:py${python.version}-h11 \
                            port:py${python.version}-h2 \
                            port:py${python.version}-hyperframe \
                            port:py${python.version}-kaitaistruct \
                            port:py${python.version}-ldap3 \
                            port:py${python.version}-mitmproxy_rs \
                            port:py${python.version}-msgpack \
                            port:py${python.version}-openssl \
                            port:py${python.version}-parsing \
                            port:py${python.version}-passlib \
                            port:py${python.version}-publicsuffix2 \
                            port:py${python.version}-pyperclip \
                            port:py${python.version}-ruamel-yaml \
                            port:py${python.version}-ruamel-yaml-clib \
                            port:py${python.version}-sortedcontainers \
                            port:py${python.version}-tornado \
                            port:py${python.version}-urwid \
                            port:py${python.version}-wsproto \
                            port:py${python.version}-zstd

    # Testing dependencies
    depends_test-append     port:py${python.version}-pytest \
                            port:py${python.version}-hypothesis \
                            port:py${python.version}-pytest-asyncio \
                            port:py${python.version}-requests

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

    post-patch {
        # Remove all upper bounds - potential breakings are detected by test
        reinplace "s/, *<\[0-9=.\]*//" ${worksrcpath}/pyproject.toml
    }

    test.run yes
    # ignore pytest.PytestDeprecationWarning since pytest 6
    test.cmd py.test-${python.branch} -W ignore::pytest.PytestDeprecationWarning
}
