# -*- 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           bitbucket 1.0
PortGroup           python 1.0
PortGroup           mpi 1.0

bitbucket.setup     khinsen scientificpython 2.9.4 rel
revision            7
checksums           rmd160  11d3cb9077cc17ea4dadac2f7887a9f76be300f3 \
                    sha256  ed5c2048a64a83cd56374d6a048c793066d0060e8589f0ec70d95caadbaaa5ed \
                    size    414165

name                py-scientific
categories-append   science
license             CeCILL-C
maintainers         nomaintainer
description         Scientific Python

python.versions     27

long_description    ScientificPython is a collection of Python modules that \
                    are useful for scientific computing.

compilers.choose    cc cxx
mpi.setup

if {${name} ne ${subport}} {
    depends_lib     port:netcdf \
                    port:py${python.version}-numpy
    build.env       "CPPFLAGS=-I${python.include} -I${worksrcpath}/Include" \
                    NETCDF_PREFIX=${prefix}

    extract.rename  yes

    platform macosx {
        post-extract {
            copy -force ${filespath}/customize.py-macosx ${worksrcpath}/customize.py
        }
    }

    platform puredarwin {
        post-extract {
            copy -force ${filespath}/customize.py-puredarwin ${worksrcpath}/customize.py
        }
    }

    if {[mpi_variant_isset]} {
        patchfiles-append patch-Src-MPI-compile.py.diff
        post-patch {
            reinplace "s|mpicompiler = 'mpicc'|mpicompiler = '${mpi.cc}'|g" \
                ${worksrcpath}/Src/MPI/compile.py
            reinplace "s|\\(-I%s\\)|\\1 -I${worksrcpath}/Include|g" \
                ${worksrcpath}/Src/MPI/compile.py
            reinplace "s|@prefix@|${prefix}|g" ${worksrcpath}/Src/MPI/compile.py
            reinplace "s|@worksrcpath@|${worksrcpath}|g" ${worksrcpath}/Src/MPI/compile.py

            system -W ${worksrcpath}/Src/MPI "${python.bin} compile.py"
        }

        post-destroot {
            xinstall ${worksrcpath}/Src/MPI/mpipython ${destroot}${prefix}/bin
        }
    }

    livecheck.type  none
}
