# -*- 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

PortSystem          1.0
PortGroup           python 1.0

name                py-pyproj
version             2.1.3
revision            0
categories-append   devel
platforms           darwin
license             MIT

python.versions     27 34 35 36 37

maintainers         {stromnov @stromnov} openmaintainer

description         Python interfaces to PROJ.4 functions.
long_description    Pyrex wrapper to provide python interfaces to PROJ.4 \
                    (http://proj.maptools.org) functions.  Performs \
                    cartographic transformations and geodetic computations.

homepage            https://pyproj4.github.io/pyproj
master_sites        pypi:[string index ${python.rootname} 0]/${python.rootname}

distname            ${python.rootname}-${version}

checksums           rmd160  71ab1853c60f388aaac5fb8b9ea4c8a9505fd6bd \
                    sha256  99c52788b01a7bb9a88024bf4d40965c0a66a93d654600b5deacf644775f424d \
                    size    521154

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

    depends_lib-append      port:proj6
    configure.env-append    PROJ_DIR=${prefix}/lib/proj6
    build.env-append        PROJ_DIR=${prefix}/lib/proj6
    destroot.env-append     PROJ_DIR=${prefix}/lib/proj6

    patchfiles-append   patch-pyproj_datadir.py.diff

    post-patch {
        reinplace "s|%%INTERNAL_DATADIR%%|${prefix}/lib/proj6/share/proj|" ${worksrcpath}/pyproj/datadir.py

        # force cython usage
        file delete ${worksrcpath}/_proj.c
    }

    post-destroot {
        xinstall -m 644 -W ${worksrcpath} \
            README.md PKG-INFO \
            ${destroot}${prefix}/share/doc/${subport}
    }

    livecheck.type      none
}