# -*- 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             3.8.0
categories-append   devel
license             MIT

python.versions     310 311 312 313 314 315

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

checksums           md5    bf9101fa60868513cfc0bf6bb9906f28 \
                    rmd160 63e37ea00f85d8148ed8143efb8f2f2b56a24535 \
                    sha256 efa59725bba68bf97fa808b61302df32934acdceb6a5c92a8dd0e71dc266a876 \
                    size   242018

if {${name} ne ${subport}} {
    if {${python.version} == 310} {
        version             3.7.1
        revision            0
        checksums           md5    ad62b11249d8e62879778190a3e3ef8c \
                            rmd160 35caafb566dbab002c3b3331810ad4bf1de03e62 \
                            sha256 60d72facd7b6b79853f19744779abcd3f804c4e0d4fa8815469db20c9f640a47 \
                            size   226339
    } elseif {${python.version} == 311} {
        version             3.7.2
        revision            0
        checksums           md5    1c0501d6055ff26565dae8fe2e6083c5 \
                            rmd160 b5ca716738701444b4b8093a8f01f53256319eb8 \
                            sha256 39a0cf1ecc7e282d1d30f36594ebd55c9fae1fda8a2622cee5d100430628f88c \
                            size   226279
    }

    depends_build-append    port:py${python.version}-cython
    depends_lib-append      port:proj9 \
                            port:py${python.version}-certifi

    configure.env-append    PROJ_DIR=${prefix}/lib/proj9
    build.env-append        PROJ_DIR=${prefix}/lib/proj9
    destroot.env-append     PROJ_DIR=${prefix}/lib/proj9
    patchfiles-append       patch-pyproj_datadir.py.diff
    post-patch {
        reinplace "s|%%INTERNAL_DATADIR%%|${prefix}/lib/proj9/share/proj|" ${worksrcpath}/pyproj/datadir.py
    }

    if {[string match *gcc-4.* ${configure.compiler}]} {
        # pycore_frame.h:134: error: ‘for’ loop initial declaration used outside C99 mode
        build.cmd-prepend       CFLAGS="-std=c99"
    }

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

    test.run                yes
    test.dir                ${destroot}${python.pkgd}
    test.env-append         PYPATH=${worksrcpath}
    test.args-append        --import-mode=importlib \
                            -k 'not input_command0] and not (test_get_data_dir and not test_get_data_dir__from_user) and not test_append_data_dir__internal' \
                            ${worksrcpath}/test
}
