# $Id: Portfile 68548 2010-06-06 01:59:48Z ram@macports.org $

PortSystem         1.0
PortGroup          python26 1.0

categories-append  graphics math
name               py26-matplotlib
version            0.99.3
maintainers        ram openmaintainer
platforms          darwin

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 numpy for \
                   handling large data sets and supports a variety of \
                   output backends. This port provides variants for the \
                   different GUIs (gtk2, tkinter, wxpython).

homepage           http://matplotlib.sourceforge.net
master_sites       sourceforge:matplotlib
distname           matplotlib-${version}

checksums          md5 c21a367dea3b98660adbb898a2f53dbc \
                   sha1 1819ac7f9b22c942ee23c635c43825cd1e8865cc \
                   rmd160 8309fc700717119c71603829890fd0eb73b376e2

depends_lib-append port:freetype \
                   port:libpng \
                   port:py26-dateutil \
                   port:py26-tz \
                   port:py26-numpy \
                   port:py26-configobj \
                   port:py26-pyobjc-cocoa

patchfiles         patch-setupext.py.diff \
                   patch-setup.cfg.diff \
                   patch-disable_optional_deps.diff \
                   patch-eintr.diff

build.env          MPLIB_BASE="${prefix}" PKG_CONFIG_PATH="${python.prefix}/lib/pkgconfig/"

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

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

post-activate {
  ui_msg "\nThe default backend is now the non-interactive Agg backend, different
backends can be specified using the ~/.matplotlib/matplotlibrc file.
More details, regarding backends, can be found in the matplotlib FAQ:
\nhttp://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend\n"
}

variant cairo description "Enable Cairo backends" {
  depends_lib-append port:py26-cairo
  post-patch {
    reinplace "s|MP_Cairo=False|MP_Cairo=True|" ${worksrcpath}/setupext.py
  }
}

variant gtk2 description "Enable GTKAgg backend" {
  depends_lib-append port:py26-gtk
  post-patch {
    reinplace "s|^gtk=False|gtk=True|" ${worksrcpath}/setup.cfg
    reinplace "s|^gtkagg=False|gtkagg=True|" ${worksrcpath}/setup.cfg
  }
}

variant tkinter description "Enable tkAgg backend" {
  post-patch {
    reinplace "s|^tkagg=False|tkagg=True|" ${worksrcpath}/setup.cfg
  }
}

variant wxpython description "Enable wxAgg backend" {
  depends_lib-append port:py26-wxpython
  post-patch {
    reinplace "s|^wxagg=False|wxagg=True|" ${worksrcpath}/setup.cfg
  }
}

variant qt4 description "Enable QT4Agg backend" {
  depends_lib-append port:py26-pyqt4
  post-patch {
    reinplace "s|MP_QT4=False|MP_QT4=True|" ${worksrcpath}/setupext.py
  }
}

variant latex description "Enable LaTeX support" {
  depends_lib-append bin:latex:texlive
  post-patch {
    reinplace "s|MP_LaTeX=False|MP_LaTeX=True|" ${worksrcpath}/setupext.py
  }
}

variant ghostscript description "Enable GhostScript support" {
  depends_lib-append port:ghostscript
  post-patch {
    reinplace "s|MP_GhostScript=False|MP_GhostScript=True|" ${worksrcpath}/setupext.py
  }
}

if { ![variant_isset gtk2] && ![variant_isset tkinter] && ![variant_isset qt4] } {
  default_variants   +tkinter
}

livecheck.type     regex
livecheck.url      http://sourceforge.net/projects/matplotlib/files/
livecheck.regex    {matplotlib-(\d+(\.\d+)*)\.tar}
