# $Id: Portfile 104414 2013-03-25 09:01:08Z and.damore@macports.org $

PortSystem          1.0
PortGroup           python 1.0
name                py-spatialite

# pyspatialite comes in several flavors according the spatialite API it's going to work with
version             2.6.2
revision            1
set spatialite-compat "-spatialite.2.3.1"

license             ZLIB
maintainers         and.damore openmaintainer
description         Python interface to SQLite 3 and Spatialite
long_description \
    pyspatialite is an interface to the SQLite 3.x embedded relational database \
    engine with spatialite extensions. It is almost fully compliant with the Python \
    database API version 2.0 also exposes the unique features of SQLite and \
    spatialite.

platforms           darwin

homepage            http://pypi.python.org/pypi/pyspatialite/${version}${spatialite-compat}
master_sites        http://pypi.python.org/packages/source/p/pyspatialite
distname            pyspatialite-${version}${spatialite-compat}

checksums           md5     9b996455e8080dbeef5f0cdcb23c16e0 \
                    sha1    f4b2785f2da727eab36297653ec330b7ad7fd114 \
                    rmd160  d3a2717cb91c774b4e8714b097cb0d0018ad67d3

# have to check if it works with 3.x
python.versions     24 25 26 27
python.default_version  27

if {${subport} != ${name}} {
    depends_lib-append \
                    port:spatialite \
                    port:geos \
                    port:proj

    patchfiles      patch-setup_py.diff \
                    patch-lib_dbapi2_py.diff \
                    patch-src_connection.diff

    post-patch {
        reinplace -locale C "s|%%PREFIX%%|${prefix}|" ${worksrcpath}/setup.py
    }

    post-destroot {
         xinstall -d ${destroot}${python.prefix}/share/doc/${subport}
         file copy ${worksrcpath}/doc ${destroot}${python.prefix}/share/doc/${subport}
         file copy ${worksrcpath}/LICENSE ${destroot}${python.prefix}/share/doc/${subport}
         file delete -force ${destroot}${python.prefix}/pyspatialite-doc
    }
}

livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     "pyspatialite-(\\d+(?:\\.\\d+)*)-spatialite.2.3.1${extract.suffix}"

