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

github.setup        Calysto octave_kernel 0.31.1 v
revision            0
set real_name       octave_kernel
name                py-${real_name}
license             BSD
maintainers         {mps @Schamschula} openmaintainer
description         A Jupyter kernel for Octave
long_description    ${description}
platforms           darwin

checksums           rmd160  fdc706beb71fab9b62682362d1f60d5fd6ce91fc \
                    sha256  e25c975e807d0da16f2b76c528f8e182dd73c18b777700dfbe1ceb1ed7a2934e \
                    size    250855

python.versions     27 36 37 38

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

    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
    }

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/
************************************************************
"
}

foreach {old new} {34 36 35 36} {
    subport py${old}-${python.rootname} "
        replaced_by py${new}-${python.rootname}
        PortGroup obsolete 1.0
    "
}