# -*- 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-bqscales
version             0.3.7
revision            0

license             Apache-2
maintainers         {mps @Schamschula} openmaintainer
description         Grammar of Graphics in Python for bqplot and other Jupyter widgets \
                    libraries
long_description    {*}${description}
homepage            https://github.com/bqplot/bqscales

checksums           rmd160  cad0389b4e777c44dfaf3cac1643685b421fe393 \
                    sha256  061488c68efba046ba166bbb9f87c8908c93b0bbe1a4636c36ca680553a121c1 \
                    size    393410

python.versions     310 311 312 313 314

python.pep517_backend \
                    hatch

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

    depends_lib-append  \
                    port:py${python.version}-ipywidgets \
                    port:py${python.version}-jupyterlab_pygments \
                    port:py${python.version}-numpy \
                    port:py${python.version}-traitlets \
                    port:py${python.version}-traittypes

    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-package.json.diff \
                    patch-pyproject.toml.diff
    
    post-patch {
        reinplace "s/%PYVERSION%/${python.branch}/g" \
            ${worksrcpath}/package.json \
            ${worksrcpath}/pyproject.toml 
    }
}
