# -*- 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-build

version             0.9.0
revision            0
categories-append   devel
license             MIT
supported_archs     noarch
platforms           {darwin any}

python.versions     36 37 38 39 310 311

maintainers         {danchr @danchr} openmaintainer

description         A simple, correct PEP517 package builder

long_description    ${description} which will invoke the PEP 517 \
                    hooks to build a distribution package. It is a \
                    simple build tool and does not perform any \
                    dependency management.

homepage            https://pypa-build.readthedocs.io/

checksums           md5 f2dc1823b0eff7037e19be18e354b2f1 \
                    rmd160 d431de8027e33f1c21dd35b8852defd590ac5198 \
                    sha256 1a07724e891cbd898923145eb7752ee7653674c511378eb9c7691aab1612bc3c \
                    size   17450

python.pep517       yes

if {${name} ne ${subport}} {
    # don't depend on ourself
    python.add_dependencies no
    depends_build-append \
                        port:py${python.version}-setuptools \
                        port:py${python.version}-wheel
    depends_lib-append  port:py${python.version}-packaging \
                        port:py${python.version}-pep517 \
                        port:python${python.version}

    if {${python.version} >= 37} {
        depends_build-append \
                        port:py${python.version}-installer
    } else {
        depends_build-append \
                        port:py${python.version}-python-install
    }
    if {${python.version} < 310} {
        # strictly speaking, only needed for python 3.7 and lower, but
        # its absense causes issues with 3.8 and 3.9 in trace mode
        depends_lib-append \
                        port:py${python.version}-importlib-metadata
    }
    if {${python.version} < 311} {
        depends_lib-append \
                        port:py${python.version}-tomli
    }

    build.env-append    PYTHONPATH=${worksrcpath}/src

    # just verify dependencies
    test.run            yes
    test.env-append     PYTHONPATH=${worksrcpath}/src
    test.cmd            ${python.bin} -m build
    test.target         --help

    livecheck.type      none
}
