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

set _name           BitArray2D

name                py-${_name}
version             2.1
categories-append   math
platforms           darwin
supported_archs     noarch

maintainers         {petr @petrrr} openmaintainer

license             PSF

description         A memory-efficient packed representation for 2D bit arrays

long_description    The BitArray2D class is for a memory-efficient packed \
                    representation of 2D bit arrays and for logical and other \
                    operations (such as blob dilations, erosions, etc.) on \
                    such arrays. The implementation of the class takes \
                    advantage of the facilities of the BitVector class for \
                    the memory representation and for the allowed operations.

homepage            https://engineering.purdue.edu/kak/dist2d/${_name}-${version}.html

distname            ${_name}-${version}
master_sites        https://engineering.purdue.edu/kak/dist2d/

checksums           md5     24cac608e52df170a5163988b95d9fa3 \
                    rmd160  6b25f62b9ea8ea7f4d680e31fa210d03574e1173 \
                    sha256  d0875cb8384a76925981fec18b88bf66927b2dcddea104e954a7874351eb8877

python.versions     27 34 35 36 37

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

    test.run            yes
    test.cmd            ${python.bin} TestBitArray2D/Test.py
    test.target         {}

    # delete redundant files & avoid testing different version
    pre-patch {
        delete {*}[glob ${worksrcpath}/*/*.pyc]            ;# purge *.pyc files
        delete {*}[glob ${worksrcpath}/*/BitVector.py]     ;# .
        delete {*}[glob ${worksrcpath}/*/BitArray2D.py]    ;# these copies

        # use version installed by dependency instead
        delete ${worksrcpath}/BitVector.py

        # create link for testing
        ln -s ../BitArray2D.py ${worksrcpath}/TestBitArray2D/BitArray2D.py
    }

    # Adding documentation & examples
    post-destroot {
        copy ${worksrcpath}/${distname}.html ${destroot}${prefix}/share/doc/${subport}
 
        # Avoid creation of example directory
        delete  ${destroot}${prefix}/share/doc/${subport}/examples
        copy ${worksrcpath}/Examples ${destroot}${prefix}/share/doc/${subport}/examples
    }

    livecheck.type      none
} else {
    livecheck.type      regex
    livecheck.url       [lindex ${master_sites} 0]
    livecheck.regex     "${_name}-(\\d+(\\.\\d+)+)\\${extract.suffix}"
}