# -*- 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             20.3.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/

set dl_version      [join [lrange [split ${version} .] 0 1] .]
master_sites        https://twistedmatrix.com/Releases/Twisted/${dl_version}
distname            Twisted-${version}
use_bzip2           yes

checksums           rmd160  d30b3dd66222e4dd3ad4ce668f1c556690e8b554 \
                    sha256  d72c55b5d56e176563b91d11952d13b01af8725c623e498db5507b6614fc1e10 \
                    size    3127793

python.versions 27 35 36 37 38 39

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
    depends_run-append \
        port:py${python.version}-pyhamcrest

    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
        }
    }

    # see https://trac.macports.org/ticket/54627
    depends_run-append \
        port:py${python.version}-automat

    livecheck.type  none
} else {
    livecheck.type   regex
    livecheck.url    https://twistedmatrix.com/trac/wiki/Downloads
    livecheck.regex  "The current release is Twisted (\\d+(?:\\.\\d+)*)"
}
