# -*- 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
PortGroup               github 1.0
PortGroup               select 1.0

github.setup            gpilab framework 1.0.5 v
name                    py-gpilab-framework
revision                1
python.versions         35 36 37
python.default_version  37
supported_archs         noarch
platforms               darwin
license                 LGPL-3
maintainers             {eborisch @eborisch} \
                        openmaintainer
description             This is the GPI Framework project.

long_description        This is the GPI Framework project. The framework \
                        constitutes the main process that provides a canvas \
                        for graphically organizing and assembling algorithm \
                        components called 'Nodes'. The framework also \
                        contains the PyFI C++ interface for simplifying the \
                        generation of Python extension modules.

homepage                http://gpilab.com

checksums \
    rmd160  5978096574f142adb13a8998c3f84308140f57c2 \
    sha256  9778c8a52ef45533eed5ce8e25c2b38bd49cdc858ee17b4a638e968a73646d9b \
    size    4114430

patchfiles                  mainWindow.py.diff \
                            canvasGraph.py.diff \
                            make.py.diff

if {${name} ne ${subport}} {
    depends_run-append      port:py${python.version}-json-tricks \
                            port:py${python.version}-numpy \
                            port:py${python.version}-opengl \
                            port:py${python.version}-pyobjc \
                            port:py${python.version}-pep8 \
                            port:py${python.version}-pillow \
                            port:py${python.version}-psutil \
                            port:py${python.version}-pyflakes \
                            port:py${python.version}-pyqt4 \
                            port:py${python.version}-qimage2ndarray \
                            port:py${python.version}-scipy \
                            port:py${python.version}-sip \
                            port:astyle \
                            path:include/eigen3/Eigen/Core:eigen3 \
                            port:fftw-3 \
                            port:fftw-3-single \
                            port:gpilab_select
                            
    livecheck.type          none


    post-patch {
        reinplace \
           -E "s^/usr/bin/env python3?^${prefix}/bin/python${python.branch}^" \
           bin/gpi_launch bin/gpi_make bin/gpi_update doc/conf.py \
           doc/FrameworkDev/devguide.rst doc/latest_version.py \
           lib/gpi/types/numpy_GPITYPE.py \
           lib/gpi/types/globjectlist_GPITYPE.py \
           lib/gpi/types/python_GPITYPE.py lib/gpi/docs.py \
           lib/gpi/numba_stub.py lib/gpi/launch.py lib/gpi/topsort.py \
           lib/gpi/make.py
        reinplace "s/import json/import json_tricks as json/" \
            lib/gpi/network.py
        reinplace "s/10\\.9/${macosx_deployment_target}/" lib/gpi/make.py
        reinplace "s^GPI_DOCS_DIR\+'^'${prefix}/share/${subport}^" \
            lib/gpi/mainWindow.py
        reinplace "s^%%PYFIPATH%%^${prefix}/share/${subport}/include^" \
            lib/gpi/make.py
    }

    use_configure no

    build {
        system -W ${worksrcpath}/lib "${python.bin} -c 'import gpi'"
    }

    destroot {
        set DD ${destroot}${prefix}
        set PP ${destroot}${python.pkgd}
        foreach bin {gpi_launch gpi_make} {
            xinstall -W ${worksrcpath}/bin ${bin} \
                ${DD}/bin/${bin}-${python.version}
        }
        xinstall -d ${DD}/share/${subport}
        xinstall -W ${worksrcpath} COPYING COPYING.LESSER LICENSE README.md \
            ${DD}/share/${subport}
        xinstall -d ${PP}
        file copy ${worksrcpath}/lib/gpi ${PP}/
        file copy ${worksrcpath}/include ${DD}/share/${subport}/
    }

    select.group    gpilab
    select.file     ${filespath}/gpilab-${python.version}

    notes "
    To make the Python ${python.branch} version of gpilab the one that is run \
    when you execute the commands without a version suffix, e.g. 'gpi_launch', \
    run:

    sudo port select --set ${select.group} [file tail ${select.file}]
    "
}