# -*- 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-twisted
version             22.10.0
categories-append   devel net
license             MIT
platforms           darwin
maintainers         {mcalhoun @MarcusCalhoun-Lopez} free.fr:olv.bonnet openmaintainer
description         An event-based Python framework for internet applications
long_description    Twisted is an event-driven networking framework \
                    written in Python. Twisted supports TCP, UDP, SSL/TLS, \
                    multicast, Unix sockets, a large number of protocols \
                    (including HTTP, NNTP, SSH, IRC, FTP, and others), and \
                    much more.

homepage            https://www.twistedmatrix.com/

python.rootname     Twisted

checksums           rmd160  96019de2a84e84b7d9d150b05432dc6418a5cbed \
                    sha256  32acbd40a94f5f46e7b42c109bfae2b302250945561783a8b7a059048f2d4d31 \
                    size    3524935

python.versions 27 35 36 37 38 39 310

if {${name} ne ${subport}} {
    # uses "from pkg_resources import load_entry_point"
    depends_lib-append    \
        port:py${python.version}-bcrypt \
        port:py${python.version}-setuptools \
        port:py${python.version}-zopeinterface \
        port:py${python.version}-incremental \
        port:py${python.version}-hyperlink \
        port:py${python.version}-constantly \
        port:py${python.version}-automat \
        port:py${python.version}-attrs
    depends_run-append \
        port:py${python.version}-pyhamcrest

    if {${python.version} == 27} {
        version     20.3.0

        checksums   rmd160  d30b3dd66222e4dd3ad4ce668f1c556690e8b554 \
                    sha256  d72c55b5d56e176563b91d11952d13b01af8725c623e498db5507b6614fc1e10 \
                    size    3127793

        use_bzip2   yes

        # Dependencies:
        # https://github.com/twisted/twisted/blob/121c98e006a31750661107d390ec2dc4ffe28e8a/src/twisted/python/_setup.py#L270
    } elseif {${python.version} == 35} {
        version     21.2.0

        checksums   rmd160  8ee4a98a79aecd9ff7eaf1570973dfda546cc3cb \
                    sha256  77544a8945cf69b98d2946689bbe0c75de7d145cdf11f391dd487eae8fc95a12 \
                    size    3727284

        # Dependencies:
        # https://github.com/twisted/twisted/blob/f1daeeee171b1cd9dae77833c66728023198b468/setup.cfg#L28
    } elseif {${python.version} >= 36} {
        # Dependencies:
        # https://github.com/twisted/twisted/blob/4e3b22afe1f76b360733b65d6b835b7aaae6deb6/setup.cfg#L28
        depends_lib-append \
            port:py${python.version}-typing_extensions
    }

    post-destroot {
        # update the plugin cache
        system "PYTHONPATH=${destroot}${python.pkgd} ${python.bin} ${filespath}/getPlugins.py"
    }
    pre-activate {
        set cachefile ${python.pkgd}/twisted/plugins/dropin.cache
        if {[file exists $cachefile] && [registry_file_registered $cachefile] == "0"} {
            file delete -force $cachefile
        }
    }

    livecheck.type  none
}
