# -*- 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
PortGroup           select 1.0

name                py-obspy
version             1.4.2
revision            0

categories-append   science
license             LGPL-3
maintainers         {petr @petrrr} openmaintainer

description         Python framework for processing seismological data
long_description    \
    ObsPy is an open-source project dedicated to provide a Python framework \
    for processing seismological data. It provides support for file formats \
    and signal processing routines which allow the manipulation, analysis \
    and visualization of seismological time series. The goal of the ObsPy \
    project is to facilitate rapid application development for seismology.

homepage            https://github.com/obspy/obspy/wiki/

checksums           rmd160  7b1dfb97149a111186096b8055e564881bed2146 \
                    sha256  dd93a17cda32be057937b551f096df07def6aa61ccf26558ce9cd1866a70397c \
                    size    17036293

python.versions     310 311 312 313

# aic_simple.c: error: redefinition of ‘i’
compiler.c_standard 2011

if {${name} ne ${subport}} {
    # py-scipy is not universal
    universal_variant       no

    depends_lib-append      port:py${python.version}-decorator \
                            port:py${python.version}-lxml \
                            port:py${python.version}-matplotlib \
                            port:py${python.version}-numpy \
                            port:py${python.version}-scipy \
                            port:py${python.version}-requests \
                            port:py${python.version}-sqlalchemy

    depends_test-append     port:py${python.version}-packaging \
                            port:py${python.version}-pyproj

    patchfiles-append       sqlalchemy2.patch

    test.run                yes
    test.args-append        -k \"not test_tsindex.py"\

    # add manpages
    depends_build-append    port:help2man

    post-build {
        set libarch [glob -tail -directory ${worksrcpath}/build lib.*]
        set libsrc build/${libarch}/obspy/lib
        set libtgt ${worksrcpath}/obspy/lib

        # hack: link to built libraries to make scripts (and help2man) work
        foreach l [glob -tail -directory ${worksrcpath}/${libsrc} *.so] {
            ln -s ../../${libsrc}/${l} ${libtgt}/.
        }

        system -W ${worksrcpath} "${python.bin} setup.py --no-user-cfg build_man"
    }
    post-destroot {
        system -W ${worksrcpath} "${python.bin} setup.py --no-user-cfg install_man --prefix=${python.prefix} --root=${destroot}"
    }

    depends_run-append  port:${python.rootname}_select

    select.group    ${python.rootname}
    select.file     ${filespath}/${python.rootname}${python.version}

    notes-append "
To make this Python ${python.branch} version of ObsPy the default \
(i.e, use its script by their default names, e.g. obspy-runtests, etc.), run:

sudo port select --set ${select.group} [file tail ${select.file}]
    "
}
