# -*- 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             25.5.0
revision            0

categories-append   devel net
license             MIT
platforms           {darwin any}
supported_archs     noarch
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/

checksums           rmd160  01aa9c6a7a43d89e286584a40f5ed90888e6aac9 \
                    sha256  1deb272358cb6be1e3e8fc6f9c8b36f78eb0fa7c2233d2dbe11ec6fee04ea316 \
                    size    3545725

python.versions     27 310 311 312 313 314
python.pep517_backend \
                    hatch

if {${name} ne ${subport}} {
    if {${python.version} != 27} {
        depends_build-append \
                    port:py${python.version}-hatch-fancy-pypi-readme
    }

    # 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 \
        port:py${python.version}-typing_extensions

    depends_run-append \
        port:py${python.version}-pyhamcrest

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

        python.rootname \
                    Twisted
        checksums   rmd160  d30b3dd66222e4dd3ad4ce668f1c556690e8b554 \
                    sha256  d72c55b5d56e176563b91d11952d13b01af8725c623e498db5507b6614fc1e10 \
                    size    3127793

        use_bzip2   yes

        depends_lib-delete \
            port:py${python.version}-typing_extensions

        # This version has an extension module, but later versions do not.
        supported_archs

        # Dependencies:
        # https://github.com/twisted/twisted/blob/121c98e006a31750661107d390ec2dc4ffe28e8a/src/twisted/python/_setup.py#L270
    }

    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
}
