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

name                py-spyder
version             6.1.0
revision            0
# the epoch is here for historical reasons and cannot be removed
epoch               20111202

categories-append   devel
platforms           {darwin any}
supported_archs     noarch
license             MIT
maintainers         {reneeotten @reneeotten} openmaintainer

description         Spyder is the Scientific PYthon Development EnviRonment
long_description    {*}${description}. \
                    Spyder is a powerful scientific environment written in Python, \
                    for Python, and designed by and for scientists, engineers and data \
                    analysts. It offers a unique combination of the advanced editing, \
                    analysis, debugging, and profiling functionality of a comprehensive \
                    development tool with the data exploration, interactive execution, \
                    deep inspection, and beautiful visualization capabilities of a \
                    scientific package.

homepage            https://www.spyder-ide.org/

checksums           rmd160  b56ea0dcb45e5849c7575a0c53a3fb0258e677c5 \
                    sha256  5200c6249bb037307455f00c80633f50884d6ab43a75ad7c5ca13d2462574636 \
                    size    13316118

python.versions     310 311 312 313

if {${name} ne ${subport}} {
    depends_run-append \
                    port:py${python.version}-aiohttp \
                    port:py${python.version}-applaunchservices \
                    port:py${python.version}-asyncssh \
                    port:py${python.version}-atomicwrites \
                    port:py${python.version}-chardet \
                    port:py${python.version}-cloudpickle \
                    port:py${python.version}-cookiecutter \
                    port:py${python.version}-diff-match-patch \
                    port:py${python.version}-importlib-metadata \
                    port:py${python.version}-intervaltree \
                    port:py${python.version}-ipython \
                    port:py${python.version}-jedi \
                    port:py${python.version}-jellyfish \
                    port:py${python.version}-jsonschema \
                    port:py${python.version}-keyring \
                    port:py${python.version}-nbconvert \
                    port:py${python.version}-numpydoc \
                    port:py${python.version}-parso \
                    port:py${python.version}-pexpect \
                    port:py${python.version}-pickleshare \
                    port:py${python.version}-psutil \
                    port:py${python.version}-pygithub \
                    port:py${python.version}-pygments \
                    port:py${python.version}-pylint \
                    port:py${python.version}-pylint-venv \
                    port:py${python.version}-pyls-spyder \
                    port:py${python.version}-pyqt5 \
                    port:py${python.version}-pyqt5-webengine \
                    port:py${python.version}-python-lsp-black \
                    port:py${python.version}-python-lsp-server \
                    port:py${python.version}-pyuca \
                    port:py${python.version}-zmq \
                    port:py${python.version}-qdarkstyle \
                    port:py${python.version}-qstylizer \
                    port:py${python.version}-qtawesome \
                    port:py${python.version}-qtconsole \
                    port:py${python.version}-qtpy \
                    port:py${python.version}-rtree \
                    port:py${python.version}-setuptools \
                    port:py${python.version}-sphinx \
                    port:py${python.version}-spyder-kernels \
                    port:py${python.version}-superqt \
                    port:py${python.version}-textdistance \
                    port:py${python.version}-three-merge \
                    port:py${python.version}-watchdog \
                    port:py${python.version}-yarl

    variant small description "Remove all optional dependencies." {}

    if {![ variant_isset small ]} {
        depends_run-append \
                    port:py${python.version}-cython \
                    port:py${python.version}-matplotlib \
                    port:py${python.version}-numpy \
                    port:py${python.version}-pandas \
                    port:py${python.version}-scipy \
                    port:py${python.version}-sympy
    }

    variant docs description "Include offline Python and Qt documentation." {
        depends_run-append \
                    port:py${python.version}-htmldocs \
                    port:qt5-docs
    }

    variant pil description "Support image objects in editor through Pillow." {
        depends_run-append \
                    port:py${python.version}-Pillow
    }

    patchfiles-append \
                    patch-spyder_config_base.py.diff \
                    patch-spyder_app_start.py.diff \
                    patch-spyder_app_utils.py.diff \
                    patch-spyder_utils_programs.py.diff \
                    patch-spyder_config_lsp.py.diff

    set PYLS_BIN_NAME   pyls-${python.branch}

    post-patch {
        reinplace "s|@@PREFIX@@|${prefix}|g" \
            ${worksrcpath}/spyder/app/utils.py
        reinplace "s|@@APPS_DIR@@|${applications_dir}/Qt5|g" \
            ${worksrcpath}/spyder/utils/programs.py
        reinplace "s|@@PYLS_BIN_NAME@@|${PYLS_BIN_NAME}|g" \
            ${worksrcpath}/spyder/config/lsp.py
    }

    post-destroot {
        delete ${destroot}${prefix}/bin/spyder_win_post_install.py-${python.branch}
        delete ${destroot}${python.prefix}/bin/spyder_win_post_install.py

        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} AUTHORS.txt LICENSE.txt README.md \
            ${destroot}${docdir}
    }

    depends_run-append \
                    port:spyder_select

    select.group    spyder
    select.file     ${filespath}/spyder-${python.version}

    notes "
To make the Python ${python.branch} version of spyder the one that is run\
when you execute the commands without a version suffix, e.g. 'spyder', run:

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