# -*- 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                    poetry
version                 1.1.4
revision                2
categories-append       devel
platforms               darwin
license                 MIT
supported_archs         noarch

maintainers             {gmail.com:davidgilman1 @dgilman} openmaintainer

description             Python dependency management and packaging made easy.

long_description        Poetry: Dependency Management for Python \
                        \
                        Poetry helps you declare, manage and install \
                        dependencies of Python projects, ensuring you have \
                        the right stack everywhere.

homepage                https://python-poetry.org/

checksums               rmd160  0d56b1b878872fcea5d9aa3a1e4ddc7b2e912a9e \
                        sha256  946a5a1173be607c7c5c593358a0fb0c0d6af4400c978929ecdb19c3a37b53a8 \
                        size    132207

variant python37 conflicts python38 python39 description {Use Python 3.7} {}
variant python38 conflicts python37 python39 description {Use Python 3.8} {}
variant python39 conflicts python37 python38 description {Use Python 3.9} {}

if {![variant_isset python37] && ![variant_isset python39]} {
    default_variants +python38
}

foreach pv {39 38 37} {
    if {[variant_isset python${pv}]} {
        python.default_version  ${pv}
        break
    }
}

# These are in pyproject.toml order
depends_lib-append \
    port:py${python.version}-poetry-core \
    port:py${python.version}-cleo \
    port:py${python.version}-clikit \
    port:py${python.version}-crashtest \
    port:py${python.version}-requests \
    port:py${python.version}-cachy \
    port:py${python.version}-requests-toolbelt \
    port:py${python.version}-cachecontrol \
    port:py${python.version}-pkginfo \
    port:py${python.version}-html5lib \
    port:py${python.version}-shellingham \
    port:py${python.version}-tomlkit \
    port:py${python.version}-pexpect \
    port:py${python.version}-packaging \
    port:py${python.version}-virtualenv \
    port:py${python.version}-keyring

# Needed for the filecache extra of the cachecontrol dependency
depends_lib-append \
    port:py${python.version}-lockfile

# Shell completion
post-destroot {
    xinstall -d "${destroot}${prefix}/etc/bash_completion.d"
    xinstall -d "${destroot}${prefix}/share/zsh/site-functions"
    system "PYTHONPATH=${destroot}${python.pkgd} ${destroot}${python.prefix}/bin/poetry completions bash > ${destroot}${prefix}/etc/bash_completion.d/poetry"
    system "PYTHONPATH=${destroot}${python.pkgd} ${destroot}${python.prefix}/bin/poetry completions zsh > ${destroot}${prefix}/share/zsh/site-functions/_poetry"
    reinplace "s|${destroot}||g" \
        ${destroot}${prefix}/etc/bash_completion.d/poetry \
        ${destroot}${prefix}/share/zsh/site-functions/_poetry
}

test.run                yes
test.cmd                ${python.bin}
test.target             -m poetry
