# $Id: Portfile 114431 2013-12-08 09:48:42Z and.damore@macports.org $

PortSystem          1.0
PortGroup           python 1.0
PortGroup           github 1.0

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

license             BSD
maintainers         nomaintainer
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}
github.setup        lokkju pyspatialite 3.0.1-alpha-0
name                py-spatialite

checksums           md5     b006a6fdc23a26400ea5b0d1ca6ab471 \
                    sha1    e9f60f6a46b6e523ddcf94fd7ec7c113985246fc \
                    rmd160  b6f7ff630e35cf0b0dbdd81b834d36c5fe162f91

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

if {${name} ne ${subport}} {
    depends_build-append \
                    port:py${python.version}-setuptools

    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}"

