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

name                py-itables
github.setup        mwouts itables 2.8.1 v
github.tarball_from archive
revision            0

categories-append   math
license             MIT
maintainers         {mps @Schamschula} openmaintainer
description         Pandas and Polar DataFrames as interactive DataTables
long_description    {*}${description}
homepage            https://mwouts.github.io/itables/

checksums           rmd160  c056b44e77dfae591395a723b69f0dcbb532a1c9 \
                    sha256  4f2e43000216bc53ee5db9d3381e3baad24af35d4295107fc0d4f4bc9b8e68e6 \
                    size    1249483

python.versions     311 312 313 314

python.pep517_backend \
                    hatch

if {${name} ne ${subport}} {
    depends_build-append \
                    port:py${python.version}-hatch-jupyter-builder

    depends_lib-append \
                    port:py${python.version}-anywidget \
                    port:py${python.version}-dash \
                    port:py${python.version}-ipython \
                    port:py${python.version}-marimo \
                    port:py${python.version}-narwhals \
                    port:py${python.version}-numpy \
                    port:py${python.version}-pandas \
                    port:py${python.version}-pyarrow \
                    port:py${python.version}-traitlets \
                    port:py${python.version}-typeguard
                    
    if {${python.version} < 311} {
        depends_lib-append \
                    port:py${python.version}-typing_extensions
    }

    platform darwin {
        if {${os.major} > 21} {
            depends_lib-append \
                    port:nodejs24
        }
        if {${os.major} > 18 && ${os.major} < 22} {
            depends_lib-append \
                    port:nodejs22
        }
        if {${os.major} > 15 && ${os.major} < 19} {
            depends_lib-append \
                    port:nodejs20
        }
        if {${os.major} > 10 && ${os.major} < 16} {
            depends_lib-append \
                    port:nodejs16
        }

        if {${os.major} > 15} {
            depends_build-append \
                    port:npm11
        }
        if {${os.major} > 12 && ${os.major} < 16} {
            depends_build-append \
                    port:npm9
        }
        if {${os.major} < 13} {
            depends_build-append \
                    port:npm8
        }
    }

    patchfiles      patch-pyproject.toml.diff \
                    patch-packages-dt_for_itables-package.json.diff \
                    patch-packages-itables_anywidget-package.json.diff \
                    patch-packages-itables_for_dash-package.json.diff

    post-patch {
        reinplace "s|%PREFIX%|${prefix}|g" \
            ${worksrcpath}/packages/dt_for_itables/package.json \
            ${worksrcpath}/packages/itables_anywidget/package.json \
            ${worksrcpath}/packages/itables_for_dash/package.json
        reinplace "s|%PYTHONBR%|${python.branch}|g" \
            ${worksrcpath}/packages/dt_for_itables/package.json \
            ${worksrcpath}/packages/itables_for_dash/package.json
    }

    variant polars {
        depends_lib-append \
                    port:py${python.version}-polars
    }
}
