# -*- 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
PortGroup           mpi 1.0

name                py-tables
version             3.11.1
revision            0

categories-append   science
license             BSD

python.versions     310 311 312 313 314

maintainers         nomaintainer

description         Package for managing hierarchical datasets
long_description    PyTables is a package for managing hierarchical datasets \
                    and designed to efficiently and easily cope with \
                    extremely large amounts of data

homepage            https://www.pytables.org/

checksums           rmd160  ad7a05556ffd0bfddddb1c73c4982384278206b1 \
                    sha256  78abcf413091bc7c1e4e8c10fbbb438d1ac0b5a87436c5b972c3e8253871b6fb \
                    size    4790533

mpi.setup

if {${name} ne ${subport}} {
    build.env-append    BLOSC_DIR=${prefix} \
                        BLOSC2_DIR=${prefix} \
                        BZIP2_DIR=${prefix} \
                        HDF5_DIR=${prefix} \
                        LZO_DIR=${prefix}
    destroot.env-append BLOSC_DIR=${prefix} \
                        BLOSC2_DIR=${prefix} \
                        BZIP2_DIR=${prefix} \
                        HDF5_DIR=${prefix} \
                        LZO_DIR=${prefix}

    depends_build-append \
                        port:py${python.version}-setuptools \
                        path:bin/pkg-config:pkgconfig \
                        port:py${python.version}-cython

    mpi.enforce_variant hdf5
    depends_lib-append  port:hdf5 \
                        port:py${python.version}-blosc2 \
                        port:py${python.version}-cpuinfo \
                        port:py${python.version}-numpy \
                        port:py${python.version}-numexpr \
                        port:zlib \
                        port:bzip2 \
                        port:lzo2 \
                        port:blosc

    post-patch {
        file rename ${worksrcpath}/src/utils.h ${worksrcpath}/src/xxx_utils.h
        set cfiles [glob -nocomplain -directory ${worksrcpath}/tables *.c]
        if {$cfiles ne ""} {
            delete {*}$cfiles
        }
        reinplace -q {s:utils\.h:xxx_utils.h:} {*}[glob ${worksrcpath}/{src,tables}/*.{c,pxd,pyx}]
    }

    post-destroot {
        xinstall -m 0755 -d ${destroot}${prefix}/share/doc/${subport}
        xinstall -m 0644 -W ${worksrcpath} LICENSE.txt README.rst THANKS \
            ${destroot}${prefix}/share/doc/${subport}
    }

    test.run        yes
    python.test_framework
    test.dir        ${destroot}${python.pkgd}/tables/tests
    test.env-append PYTHONPATH=${destroot}${python.pkgd}
    test.cmd        ${python.bin} test_all.py
}
