# -*- 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 89027 2012-01-18 10:13:55Z stromnov@macports.org $

PortSystem      1.0
PortGroup       python 1.0

name            py-scientific
version         2.9.1
categories      python science
license         CeCILL-C
platforms       darwin
maintainers     adfernandes openmaintainer
description     Scientific Python

python.versions     25 26 27
python.default_version 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.cru.fr/frs/download.php/3420/
distname        ScientificPython-${version}

checksums           md5     f27bfb3abda022b73a93cd6ada06338f \
                    sha1    595f62133d6a013e4298e7c4e80e755ad971fe89 \
                    rmd160  d2c1822cd4ec0b42588f90fa2551d109f462f43b

if {$subport != $name} {
    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
    }
}

variant openmpi description {Enable openmpi support} conflicts mpi {
    depends_lib-append  port:openmpi

    post-patch {
        reinplace "s|mpicompiler = 'mpicc'|mpicompiler = 'openmpicc'|g" \
           ${worksrcpath}/Src/MPI/compile.py
        reinplace "s|\\(-I%s\\)|\\1 -I${worksrcpath}/Include|g" \
           ${worksrcpath}/Src/MPI/compile.py

        system "cd ${worksrcpath}/Src/MPI && ${python.bin} compile.py"
    }

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

variant mpi description {Enable lammpi support} conflicts openmpi {
    depends_lib-append  port:lammpi
    patchfiles-append patch-Src-MPI-compile.py.diff
    post-build {
        reinplace "s|@prefix@|${prefix}|g" ${worksrcpath}/Src/MPI/compile.py
        reinplace "s|@worksrcpath@|${worksrcpath}|g" ${worksrcpath}/Src/MPI/compile.py
        system "cd ${worksrcpath}/Src/MPI && ${prefix}/bin/python${python.branch} compile.py"
    }
    post-destroot {
        xinstall ${worksrcpath}/Src/MPI/mpipython ${destroot}${python.prefix}/bin
        ln -s ${python.prefix}/bin/mpipython ${destroot}${prefix}/bin/mpipython-${python.branch}
    }
}
}

livecheck.type  regex
livecheck.url   http://sourcesup.cru.fr/projects/scientific-py/
livecheck.regex {<strong>Stable Releases</strong></td><td>(\d+(?:\.\d+)*)}
