• [gentoo-dev] [PATCH 2/2] tree-sitter-grammar.eclass: support opt in pyt

    From Arthur Zamarin@21:1/5 to All on Wed Mar 20 22:00:01 2024
    New tree-sitter cli generated bindings and code around grammars and
    parsers now support bulding a python wheel which supply much better
    API and library for consumers in python bindings.

    Currently I've added only python as a binding languages, even though
    rust, swift, and go are also available. We should add them when we
    see a request for them. Python will be needed for pkgcheck.

    When we opt in into python bindings, we call the matching distutils
    phase functions when `use python` is true.

    Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
    ---
    eclass/tree-sitter-grammar.eclass | 85 ++++++++++++++++++++++++++++++-
    1 file changed, 84 insertions(+), 1 deletion(-)

    diff --git a/eclass/tree-sitter-grammar.eclass b/eclass/tree-sitter-grammar.eclass
    index 13539daf7e6..b04d5ee1103 100644
    --- a/eclass/tree-sitter-grammar.eclass
    +++ b/eclass/tree-sitter-grammar.eclass
    @@ -36,6 +36,43 @@ RESTRICT+=" !test? ( test )"
    # Used to override upstream tag name if tagged differently, e.g. most releases
    # are v${PV} but some are tagged as rust-${PV}.

    +# @ECLASS_VARIABLE: TS_BINDINGS
    +# @PRE_INHERIT
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Array of bindings language to build. Currently only "python" is supported.
    +
    +for _BINDING in "${TS_BINDINGS[@]}"; do
    + case ${_BINDING} in
    + python)
    + DISTUTILS_EXT=1
    + DISTUTILS_OPTIONAL=1
    + DISTUTILS_USE_PEP517=setuptools
    + PYTHON_COMPAT=( python3_{10..12} )
    + inherit distutils-r1
    +
    + IUSE+=" python"
    + REQUIRED_USE+=" python? ( ${PYTHON_REQUIRED_USE} )"
    +
    + DEPEND+=" python? (
    +