# -*- 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.2.0
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  1568fcb7cbf5f4ee9b4b912538e303dc4d38d723 \
                    sha256  0a4f793cc93539c2292638c498e24422a2ec4b25cb47545addea07724b2a56e5 \
                    size    378221

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
}