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

github.setup            h5py h5py 3.13.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
name                    py-h5py

# h5py needs to be re-built after hdf5 upgrades; it has its own version
# check included.
revision                0

checksums \
    rmd160  e2a523086a2efe94b19a344fa70d18ade2c5a43d \
    sha256  f03d551e5b45b832e9f7ded2ed4cc76d03b16de69ca054e8947bcbcf561581e7 \
    size    430963

license                 BSD
maintainers             {eborisch @eborisch} openmaintainer

description             Read and write HDF5 files from Python

long_description  \
    The h5py package provides both a high- and low-level interface to the \
    HDF5 library from Python. The low-level interface is intended to be a \
    complete wrapping of the HDF5 API, while the high-level component \
    supports  access to HDF5 files, datasets and groups using established \
    Python and NumPy concepts. \
    \n\nA strong emphasis on automatic conversion between Python (Numpy) \
    datatypes and data structures and their HDF5 equivalents vastly \
    simplifies the process of reading and writing data from Python.

homepage                https://www.h5py.org

python.versions         39 310 311 312 313

# Only check against releases.
github.livecheck.regex      {([0-9.]+)}

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

    depends_lib-append      port:py${python.version}-numpy \
                            port:hdf5

    build.env-append        HDF5_DIR=${prefix}
    destroot.env-append     HDF5_DIR=${prefix}

    patchfiles-append       patch-oldest-supported-numpy.diff

    post-destroot {
        xinstall -d ${destroot}${prefix}/share/doc/${subport}
        copy ${worksrcpath}/lzf/LICENSE.txt \
            ${destroot}${prefix}/share/doc/${subport}
    }

    # Add MPI support
    mpi.setup
    if {[mpi_variant_isset]} {
        build.env-append        DISTUTILS_DEBUG=1
        depends_lib-append      port:py${python.version}-mpi4py
        mpi.enforce_variant     hdf5 \
                                py${python.version}-mpi4py

        build.env-append        HDF5_MPI=ON
        destroot.env-append     HDF5_MPI=ON
    }
}
