# -*- 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-simpy
version             4.1.1

platforms           {darwin any} freebsd
license             MIT
maintainers         {mcalhoun @MarcusCalhoun-Lopez} openmaintainer

supported_archs     noarch

description         python based simulation language
long_description    SimPy is an object-oriented, process-based \
                    discrete-event simulation language based on standard Python.

homepage            https://simpy.readthedocs.io

checksums           rmd160  504c5004c221dbb4c9c69904758ffa6575def77f \
                    sha256  06d0750a7884b11e0e8e20ce0bc7c6d4ed5f1743d456695340d13fdff95001a6 \
                    size    408997

python.versions     39 310 311 312

if {${name} eq ${subport}} {
    revision                1
} elseif {![string match *-docs ${subport}]} {
    revision                0

    depends_build-append    port:py${python.version}-setuptools_scm

    test.run                yes
    test.args               -o addopts="-m 'not benchmark'"

    livecheck.type          none
} else {
    revision                0
    installs_libs           no

    set no_doc_subport      [string trimright ${subport} -docs]

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

    build.dir               ${worksrcpath}/docs
    build.cmd               make
    build.target            html man
    build.args              SPHINXBUILD=${prefix}/bin/sphinx-build-${python.branch}

    destroot {
        set  doc_build_dir  ${worksrcpath}/docs/_build

        file delete -force  ${doc_build_dir}/html/.buildinfo \
                            ${doc_build_dir}/html/_sources

        copy                ${doc_build_dir}/html \
                            ${destroot}${prefix}/share/doc/${no_doc_subport}

        xinstall -d         ${destroot}${python.prefix}/share/man
        copy                ${doc_build_dir}/man \
                            ${destroot}${python.prefix}/share/man/man1

        xinstall -d         ${destroot}${prefix}/share/examples
        copy                ${worksrcpath}/docs/examples \
                            ${destroot}${prefix}/share/examples/${no_doc_subport}
    }

    livecheck.type          none
}

foreach v ${python.versions} {
    subport py${v}[string trimleft $name py]-docs {}
}
