# Id$

PortSystem               1.0
PortGroup                python25 1.0
categories-append        graphics math
name                     py25-matplotlib
version                  0.90.1
revision                 0
maintainers              openmaintainer@macports.org jochen@macports.org

description              matlab-like syntax for creating plots in python
long_description         Matplotlib is a pure python plotting library with the goal of making \
                         publication quality plots using a syntax familiar to matlab users. \
                         The library uses numarray, Numeric, or numpy for handling large \
                         data sets and supports a variety of output backends. \
                         This port provides variants for the different \
                         array-objects (numarray, Numeric, numpy) and \
                         for different GUIs (gtk2, tkinter, wxpython).
homepage                 http://matplotlib.sourceforge.net
master_sites             sourceforge:matplotlib
distname                 matplotlib-${version}
checksums                md5 e1344bd72660e7c9c0b7540a72cc45b8

platforms                darwin

depends_lib-append       port:antigraingeometry \
                         port:freetype \
                         port:libpng \
                         port:py25-dateutil port:py25-tz

patchfiles               patch-setupext.py.diff 

build.env                MPLIB_BASE="${prefix}"


post-extract {
        if {[variant_isset gtk2]} {
                reinplace "s|^BUILD_GTKAGG\[\[:space:\]\]*=\[\[:space:\]\]*'auto'|BUILD_GTKAGG=1|" \
                  ${worksrcpath}/setup.py
                reinplace "s|^BUILD_GTK\[\[:space:\]\]*=\[\[:space:\]\]*'auto'|BUILD_GTK=1|" \
                  ${worksrcpath}/setup.py
        } else {
                reinplace "s|^BUILD_GTKAGG\[\[:space:\]\]*=\[\[:space:\]\]*'auto'|BUILD_GTKAGG=0|" \
                  ${worksrcpath}/setup.py
                reinplace "s|^BUILD_GTK\[\[:space:\]\]*=\[\[:space:\]\]*'auto'|BUILD_GTK=0|" \
                  ${worksrcpath}/setup.py
        }
        if {[variant_isset tkinter]} {
                reinplace "s|^BUILD_TKAGG\[\[:space:\]\]*=\[\[:space:\]\]*'auto'|BUILD_TKAGG=1|" \
                        ${worksrcpath}/setup.py
        } else {
                reinplace "s|^BUILD_TKAGG\[\[:space:\]\]*=\[\[:space:\]\]*'auto'|BUILD_TKAGG=0|" \
                        ${worksrcpath}/setup.py
        }
        if {[variant_isset wxpython]} {
                reinplace "s|^BUILD_WXAGG\[\[:space:\]\]*=\[\[:space:\]\]*'auto'|BUILD_WXAGG=1|" \
                  ${worksrcpath}/setup.py
        } else {
                reinplace "s|^BUILD_WXAGG\[\[:space:\]\]*=\[\[:space:\]\]*'auto'|BUILD_WXAGG=0|" \
                  ${worksrcpath}/setup.py
        }
        if {[variant_isset numarray]} {
                reinplace "s|NUMERIX.-1.|'numarray'|" ${worksrcpath}/setup.py 
        }
        if {[variant_isset numeric]} {
                reinplace "s|NUMERIX.-1.|'numeric'|" ${worksrcpath}/setup.py 
        }
        if {[variant_isset numpy]} {
                reinplace "s|NUMERIX.-1.|'numpy'|" ${worksrcpath}/setup.py 
        }
}

post-patch { 
        reinplace "s|@@DPORTS_PREFIX@@|${prefix}|" ${worksrcpath}/setupext.py 
}

post-destroot {
        xinstall -m 755 -d ${destroot}/${prefix}/share/doc/${name} \
                ${destroot}/${prefix}/share/matplotlib
        xinstall -m 644 -W ${worksrcpath} API_CHANGES CHANGELOG INSTALL \
                INTERACTIVE KNOWN_BUGS README TODO \
                ${destroot}/${prefix}/share/doc/${name}
        file copy ${worksrcpath}/license \
                ${destroot}/${prefix}/share/doc/${name}
        file copy ${worksrcpath}/examples \
                ${destroot}/${prefix}/share/matplotlib
}

variant gtk2 conflicts tkinter wxpython description "Use gtkAgg for interactive plotting" {
        depends_lib-append      port:py-gtk2
}
variant tkinter conflicts gtk2 wxpython description "Use tkAgg for interactive plotting" {
        depends_lib-append      port:py-tkinter
}
variant wxpython conflicts gtk2 tkinter description "Use wxAgg for interactive plotting" {
        depends_lib-append      port:py-wxpython
}
variant numarray conflicts numpy Numeric description "Use numarray as array-object" {
        depends_lib-append      port:py-numarray
}
variant Numeric conflicts numarray numpy description "Use Numeric as array-object" {
        depends_lib-append      port:py-numeric
}
variant numpy conflicts numarray Numeric description "Use numpy as array-object" {
        depends_lib-append      port:py-numpy
}
if { ![variant_isset gtk2] && ![variant_isset tkinter] && ![variant_isset wxpython] } {
        default_variants        +tkinter
}
if { ![variant_isset numarray] && ![variant_isset Numeric] && ![variant_isset numpy] } {
        default_variants        +numpy
}
