# -*- 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
# $Id: Portfile 117856 2014-03-14 22:55:47Z sean@macports.org $

PortSystem          1.0
PortGroup           python 1.0
PortGroup           mpi 1.0

compilers.choose    cc cxx
mpi.choose
mpi.setup

name                py-scientific
version             2.9.3
categories-append   science
license             CeCILL-C
platforms           darwin
maintainers         sean openmaintainer
description         Scientific Python

python.versions     26 27

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

homepage            http://dirac.cnrs-orleans.fr/ScientificPython/
master_sites        https://sourcesup.renater.fr/frs/download.php/4425/
distname            ScientificPython-${version}
fetch.ignore_sslcert yes

checksums           rmd160  9680f4dca583f49ffdfdecbe9c3cf0704d3c18c3 \
                    sha256  a4dfc55c2ec84a0795b0641e5571b79b25a5ef6d92bbb01e934c298ee34b5bc8

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}

    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
} else {
    livecheck.type  regexm
    livecheck.url   http://sourcesup.renater.fr/projects/scientific-py/
    livecheck.regex {<strong>Development Releases</strong>\s*</td>\s*<td>(\d+(?:\.\d+)*)}
}
