# -*- 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-pypcap
version                 1.1
revision                1
categories-append       net
license                 BSD
maintainers             gmail.com:andrew.reusch openmaintainer
description             python extension module for libpcap
long_description        A simplified object-oriented Python extension module for libpcap

homepage                https://code.google.com/p/pypcap/
master_sites            googlecode:pypcap
distname                pypcap-${version}

checksums               md5     034c3cbbfa81aa19e8f685b767c65764 \
                        sha1    966f62deca16d5086e2ef6694b0c795f273da15c \
                        rmd160  119dcc393d42678e6fa8f0b0f8b82536ab1efb13

python.versions         310 311 312 313

if {$subport ne $name} {
    depends_build-append    port:py${python.version}-cython
    depends_lib-append      port:libpcap

    patchfiles          setup.py.patch pcap.pyx.patch

    python.pep517   yes
    patchfiles-append   py3.patch
    post-patch {
        system -W ${worksrcpath} "${python.prefix}/bin/2to3 --write --nobackups setup.py"
    }

    pre-configure {
        delete ${worksrcpath}/pcap.c
        system -W ${worksrcpath} "${python.prefix}/bin/cythonize pcap.pyx"
    }
    use_configure       yes
    configure.cmd       ${python.bin} setup.py
    configure.args      config
    configure.pre_args
    configure.post_args  --with-pcap="${prefix}"

    build.env-append    SETUP_PY_LOAD_PCAP_CONFIG=1
    destroot.env-append SETUP_PY_LOAD_PCAP_CONFIG=1
}
