# -*- 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-sunpy
version             5.1.0
revision            0
categories          python
license             BSD
maintainers         {mps @Schamschula} openmaintainer
description         SunPy is an open-source Python library for Solar Physics data \
                    analysis and visualization.
long_description    {*}${description}
supported_archs     noarch
platforms           {darwin any}
homepage            https://sunpy.org

python.versions     38 39 310 311

checksums           rmd160  c7faa39b9c9b035cc8849812cf1a7bcfb88361c0 \
                    sha256  0b95272a9d04ab3c521d3a247522667c838c048eb25e95926b34f17122ce22f2 \
                    size    3654497

platforms {darwin >= 11}

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

    depends_lib-append \
                    port:py${python.version}-astropy \
                    port:py${python.version}-numpy \
                    port:py${python.version}-packaging \
                    port:py${python.version}-parfive

    if {${python.version} == 38} {
        version     4.1.7
        revision    0

        checksums   rmd160  88ef7c6b361e37f86e18b89c7cb70aaf55c2c87b \
                    sha256  51e5a312c69f21b4f05eeb15749cddfa843144b27d773ebee7ce1c748ef29230 \
                    size    3612301
    } else {
        python.pep517   yes
    }

    # Note:
    # the asdf variant requires py311-obspy which is missing dependencies.
    if {${python.version} < 311} {
        variant asdf {
            depends_lib-append \
                        port:py${python.version}-pyasdf
        }
    }

    variant dask {
        depends_lib-append \
                    port:py${python.version}-dask
    }

    variant database {
        depends_lib-append \
                    port:py${python.version}-sqlalchemy
    }

    variant image {
        depends_lib-append \
                    port:py${python.version}-scikit-image
    }

    variant map {}

    variant net {
        depends_lib-append \
                    port:py${python.version}-beautifulsoup4 \
                    port:py${python.version}-dateutil \
                    port:py${python.version}-drms \
                    port:py${python.version}-tqdm \
                    port:py${python.version}-zeep
    }

    variant timeseries {
        depends_lib-append \
                    port:py${python.version}-h5netcdf
    }

    variant visualization {}

    if {[variant_isset map] || [variant_isset timeseries] \
            || [variant_isset visualization]} {
        depends_lib-append \
                    port:py${python.version}-matplotlib
    }

    if {[variant_isset net] || [variant_isset timeseries]} {
        depends_lib-append \
                    port:py${python.version}-pandas
    }

    if {[variant_isset image] || [variant_isset map]} {
        depends_lib-append \
                    port:py${python.version}-scipy
    }

    default_variants +database +image +map +net +timeseries +visualization

    post-patch {
        reinplace "s|oldest-supported-numpy|numpy|g" ${worksrcpath}/pyproject.toml
    }
}
