# -*- 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 65908 2010-04-02 22:28:17Z jmr@macports.org $

PortSystem              1.0
PortGroup               python26 1.0

name                    py26-pymvpa
version                 0.4.3
categories              python

platforms               darwin
maintainers             jameskyle

description             PyMVPA is a Python module intended to ease pattern classification analyses of large datasets.

long_description        ${description}. In the neuroimaging contexts such analysis techniques are also known as decoding or MVPA analysis. PyMVPA provides high-level abstraction of typical processing steps and a number of implementations of some popular algorithms.

homepage                http://www.pymvpa.org
fetch.type              git
git.url                 http://git.debian.org/git/pkg-exppsy/pymvpa.git
git.branch              upstream/${version}

depends_lib             port:py26-numpy \
                        port:git-core \
                        port:py26-distribute \
                        port:py26-scipy \
                        port:py26-pynifti \
                        port:py26-hcluster \
                        port:libsvm \
                        port:swig-python \
                        port:py26-pywavelets \
                        port:shogun \
                        port:py26-matplotlib

depends_build           port:git-core

configure.env           CC=${prefix}/bin/gcc-mp-4.3 \
                        CPP=${prefix}/bin/gcc-mp-4.3

build.env           CC=${prefix}/bin/gcc-mp-4.3 \
                    CPP=${prefix}/bin/gcc-mp-4.3 \
                    CCFLAGS="-I${prefix}/include -L${prefix}/lib" \
                    CPPFLAGS="-I${prefix}/include -L${prefix}/lib"

destroot.env           CC=${prefix}/bin/gcc-mp-4.3 \
                       CPP=${prefix}/bin/gcc-mp-4.3 \
                       CCFLAGS="-I${prefix}/include -L${prefix}/lib" \
                       CPPFLAGS="-I${prefix}/include -L${prefix}/lib"

configure.args          --with-libsvm
build.args              --with-libsvm
patch.pre_args          -p1

patchfiles              patch-mvpa.diff setup-py.diff

build.target            build_ext

configure.compiler      macports-gcc-4.3
pre-fetch {
    if {[file exists ${prefix}/share/doc/mvpa]} {
        ui_error "It appears the 2.5 version of mvpa is installed"
        ui_error "Only one version of pymvpa can be installed at one time"
        return -code error "multiple mvpa installs detected"
    }


    if {![variant_isset no_shogun]} {
      if {![file exists ${python.pkgd}/sg.so]} {
        ui_error "To install pymvpa with the shogun variant, shogun must be installed with the python variant."
        return -code error "incompatible shogun installation"
      }
    }

}

variant no_shogun description {Do not build shogun} {
    depends_lib-delete port:shogun
}
post-destroot {
  xinstall -m 755 -d "${destroot}${prefix}/share/doc/"
  file delete ${worksrcpath}/doc/todo.txt
  file delete ${worksrcpath}/doc/legal.txt
  file delete ${worksrcpath}/doc/changelog.txt

  file copy ${worksrcpath}/TODO ${worksrcpath}/doc/
  file copy ${worksrcpath}/COPYING ${worksrcpath}/doc/
  file copy ${worksrcpath}/Changelog ${worksrcpath}/doc/
  file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/mvpa
}

livecheck.url   http://git.debian.org/?p=pkg-exppsy/pymvpa.git
livecheck.regex {upstream\/([0-9.]+)}
