# -*- 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 91493 2012-04-03 14:50:09Z eborisch@macports.org $

PortSystem          1.0
name                py-spyder
version             2.1.9
epoch               20111202

PortGroup           python 1.0

python.versions     26 27
python.default_version 27

PortGroup           qt4 1.0
categories          python devel
platforms           darwin
maintainers         eborisch openmaintainer
license             MIT
homepage            http://packages.python.org/spyder/
description         Spyder is the Scientific PYthon Development EnviRonment
long_description    ${description}. \
                    Spyder provides a powerful interactive development \
                    environment for the Python language with advanced \
                    editing, interactive testing, debugging and introspection \
                    features as well as a numerical computing environment \
                    thanks to the support of IPython (enhanced interactive \
                    Python interpreter) and popular Python libraries such as \
                    NumPy (linear algebra), SciPy (signal and image \
                    processing) or matplotlib (interactive 2D/3D plotting) \
                    development environment with advanced editing, \
                    interactive testing, debugging and introspection features.

master_sites        googlecode:spyderlib
distname            spyder-${version}
use_zip             yes
supported_archs     noarch

#pyNN-scipy doesn't build universal
universal_variant   no 

checksums           md5     051a4540ccca49976beec93c2d1f3d32 \
                    sha1    7624a37d8e9266243113dc42e58455d8535fddb0 \
                    rmd160  d9850ecb6b63d17dd50856006f3c29c5582f36e7

if {${subport} != ${name}} {
    conflicts           port:py${python.version}-spyder-beta
    
    # Set the pylint executable name
    set LINT_BIN_NAME   pylint-${python.branch}
    set WINPDB_BIN_NAME winpdb-${python.branch}
    patchfiles          patch-widgets-pylintgui.py.diff \
                        spyderlib_plugins_editor.py.diff \
                        spyderlib_spyder.py.diff \
                        spyderlib_utils_programs.py.diff \
                        spyderlib_widgets_sourcecode_codeeditor.py.diff

    post-patch {
        reinplace "s|@@WINPDB_BIN_NAME@@|${WINPDB_BIN_NAME}|g" \
            ${worksrcpath}/spyderlib/plugins/editor.py
        reinplace "s|@@LINT_BIN_NAME@@|${LINT_BIN_NAME}|g" \
            ${worksrcpath}/spyderplugins/widgets/pylintgui.py
        reinplace "s|\"assistant\"|\"Assistant\"|g" \
            ${worksrcpath}/spyderlib/spyder.py
        reinplace "s|\"linguist\"|\"Linguist\"|g" \
            ${worksrcpath}/spyderlib/spyder.py
        reinplace "s|\"designer\"|\"Designer\"|g" \
            ${worksrcpath}/spyderlib/spyder.py
        reinplace "s|@@PREFIX@@|${prefix}|g" \
            ${worksrcpath}/spyderlib/spyder.py
        reinplace "s|@@APPS_DIR@@|${applications_dir}|g" \
            ${worksrcpath}/spyderlib/utils/programs.py
        # Windows newlines in the file cause compile() (in 2.6) to choke
        reinplace "s|\r||g" \
            ${worksrcpath}/doc/conf.py
    }

    depends_lib-append  \
        port:py${python.version}-h5py \
        port:py${python.version}-htmldocs \
        port:py${python.version}-ipython \
        port:py${python.version}-lint \
        port:py${python.version}-matplotlib \
        port:py${python.version}-pep8 \
        port:py${python.version}-pil \
        port:py${python.version}-pyflakes \
        port:py${python.version}-pyqt4 \
        port:py${python.version}-rope \
        port:py${python.version}-scipy \
        port:py${python.version}-sphinx
    
    post-destroot {
        if {${python.version} == ${python.default_version}} {
          ln -s ${python.prefix}/bin/spyder ${destroot}${prefix}/bin/
        }
        set OPTCMD    [concat "export HOME=${destroot}/tmp/spyder &&" \
                       "export PYTHONPATH=${destroot}${python.pkgd} &&" \
                       "./spyder --optimize"]
        
        file mkdir ${destroot}/tmp/spyder
        system "cd ${destroot}${python.prefix}/bin && ${OPTCMD}"
        file delete -force ${destroot}/tmp/spyder
    }
}

livecheck.type      regex
livecheck.url       http://code.google.com/p/spyderlib/
livecheck.regex     spyder-(\[0-9\]+\.\[0-9\]+(\.\[0-9\]+)?)
