# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           python 1.0
PortGroup           github 1.0

github.setup        lokkju pyspatialite 3.0.1-alpha-0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                py-spatialite
version             3.0.1
revision            8

# pyspatialite comes in several flavors according the spatialite API it's going to work with
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.

checksums           md5     b006a6fdc23a26400ea5b0d1ca6ab471 \
                    sha1    e9f60f6a46b6e523ddcf94fd7ec7c113985246fc \
                    rmd160  b6f7ff630e35cf0b0dbdd81b834d36c5fe162f91

# have to check if it works with 3.x
python.versions     27

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

    depends_lib-append \
                    port:spatialite \
                    port:geos \
                    port:proj4

    patchfiles      patch-setup_py.diff \
                    patch-connection_h.diff

    set proj4_prefix ${prefix}/lib/proj49

    post-patch {
        reinplace -locale C "s|%%PROJ4_PREFIX%%|${proj4_prefix}|" ${worksrcpath}/setup.py
        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
    }
}
