# -*- 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-octave_kernel
version             1.1.0
revision            0

categories-append   devel science
license             BSD
maintainers         {mps @Schamschula} openmaintainer
description         A Jupyter kernel for Octave
long_description    {*}${description}
homepage            https://github.com/Calysto/octave_kernel

checksums           rmd160  33664234b112ba17c37a02494c10fc1b66382121 \
                    sha256  2c6e907a126b2d1c9b37900460bf8c66442e7aea9071aaa7c4b4834d39554961 \
                    size    566943

python.versions     310 311 312 313 314

python.pep517_backend \
                    hatch

if {${name} ne ${subport}} {
    depends_lib-append  \
                    port:octave \
                    port:py${python.version}-ipykernel \
                    port:py${python.version}-jupyter_client \
                    port:py${python.version}-metakernel \
                    port:py${python.version}-rpds-py

    post-destroot {
        xinstall -d  ${destroot}${prefix}/share/${subport}
        xinstall -m 640 ${filespath}/kernel.json ${destroot}${prefix}/share/${subport}
        reinplace "s/%PYVERSION%/${python.branch}/g" ${destroot}${prefix}/share/${subport}/kernel.json
        reinplace "s|%FRAMEWORKS_DIR%|${frameworks_dir}|g" ${destroot}${prefix}/share/${subport}/kernel.json
    }

    if {${python.version} == 310} {
        version     0.36.0
        revision    0

        checksums   rmd160  1c1b7da2820d7f4643d08a4b8d070e3d3fc0e746 \
                    sha256  925882f8915c86ed75b6db8e1341deed980dba0be73bf07365d3ea08961a1ddb \
                    size    262878
    }

notes "
************************************************************
In order for py-notebook to access octave_kernel,
octave_kernel needs to install a file in each user's
~/Library folder:

mkdir -p ~/Library/Jupyter/kernels/octave/
cp ${prefix}/share/${subport}/kernel.json ~/Library/Jupyter/kernels/octave/
************************************************************
"
}
