# -*- 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-ipympl
version             0.9.8
revision            0

license             BSD
maintainers         nomaintainer
description         Matplotlib Jupyter Extension
long_description    Leveraging the Jupyter interactive widgets framework, \
                    jupyter-matplotlib enables the interactive features of \
                    matplotlib in the Jupyter notebook and in Jupyterlab.

homepage            https://github.com/matplotlib/jupyter-matplotlib

supported_archs     noarch
platforms           {darwin any}

python.versions     310 311 312 313 314

checksums           rmd160  ff45a6b155aa09c00e53b61271452d24f8821b45 \
                    sha256  6d7230d518384521093f3854f7db89d069dcd9c28a935b371e9c9f126354dee1 \
                    size    58483988

python.pep517_backend \
                    hatch

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

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

    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
        }
   }

    patchfiles          patch-package.json.diff

    post-patch {
        reinplace "s|%PYVER%|${python.branch}|g" ${worksrcpath}/package.json
        reinplace "s|jlpm|jlpm-${python.branch}|g" \
            ${worksrcpath}/package.json ${worksrcpath}/pyproject.toml \
            ${worksrcpath}/ipympl/nbextension/index.js \
            ${worksrcpath}/ipympl/labextension/package.json \
            ${worksrcpath}/ui-tests/package.json \
            ${worksrcpath}/ui-tests/playwright.config.js
    }
}
