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

github.setup        palantir python-language-server 0.26.0
revision            0
name                py-language-server
categories-append   devel
license             MIT
maintainers         {gmail.com:ottenr.work @reneeotten} openmaintainer
description         An implementation of the Language Server Protocol for Python
long_description    ${description}

platforms           darwin
supported_archs     noarch

checksums           rmd160  144f00eb59b7c48dbc0e44a743f14d633550d835 \
                    sha256  eb01671c181a7af58f38d944127cbfa5616ce9445a06043100690f1842212cbb \
                    size    443739

python.versions     27 35 36 37

if {${subport} ne ${name}} {
    depends_lib-append \
                    port:py${python.version}-autopep8 \
                    port:py${python.version}-codestyle \
                    port:py${python.version}-docstyle \
                    port:py${python.version}-flake8-mccabe \
                    port:py${python.version}-future \
                    port:py${python.version}-jedi \
                    port:py${python.version}-pluggy \
                    port:py${python.version}-pyflakes \
                    port:py${python.version}-pylint \
                    port:py${python.version}-python-jsonrpc-server \
                    port:py${python.version}-rope \
                    port:py${python.version}-setuptools \
                    port:py${python.version}-yapf

    if {${python.version} eq 27} {
        depends_lib-append  port:py${python.version}-backports-functools_lru_cache \
                            port:py${python.version}-configparser \
                            port:py${python.version}-futures
    }

    depends_test-append \
                    port:py${python.version}-pytest \
                    port:py${python.version}-mock

    test.run        yes
    test.cmd        py.test-${python.branch}
    test.args       -o addopts=''
    test.target
    test.env        PYTHONPATH=${worksrcpath}/build/lib

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

    depends_run-append \
                    port:python-language-server_select

    select.group    python-language-server
    select.file     ${filespath}/py${python.version}-pyls

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

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

    livecheck.type  none
}