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

github.setup            bpython bpython 0.24 "" -release
github.tarball_from     archive
name                    py-${name}
revision                0

platforms               {darwin any}
supported_archs         noarch
maintainers             {aronnax @lpsinger} openmaintainer
license                 MIT
description             fancy interface to the Python interpreter
long_description        a fancy interface to the Python interpreter for \
                        Unix-like operating systems

homepage                https://www.bpython-interpreter.org
checksums               rmd160  0137002b419d27edd596cb585a655f83a9bd1688 \
                        sha256  445468a66353b33f3e91a59e082a35ce24b2ea0ad05820047045611c8ccfd8d4 \
                        size    221484
python.versions         39 310 311

if {${name} ne ${subport}} {
    post-patch {
        # fix version detection
        set versionpath ${worksrcpath}/bpython/_version.py
        copy ${filespath}/_version.py ${versionpath}
        reinplace "s/__VERSION__/${version}/" ${versionpath}
    }

    depends_build-append    port:py${python.version}-babel \
                            port:py${python.version}-sphinx

    depends_lib-append      port:py${python.version}-curtsies \
                            port:py${python.version}-greenlet \
                            port:py${python.version}-pygments \
                            port:py${python.version}-requests \
                            port:py${python.version}-pyxdg

    depends_run-append      port:py${python.version}-jedi \
                            port:py${python.version}-urwid \
                            port:py${python.version}-watchdog \
                            port:bpython_select

    post-destroot {
        set themedir ${destroot}${python.prefix}/share/themes
        xinstall -d ${themedir}
        xinstall -W ${worksrcpath}/theme sample.theme light.theme \
                ${themedir}
    }

    test.run                yes
    test.args               --deselect bpython/test/test_interpreter.py::TestInterpreter::test_syntaxerror

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

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

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