Name: python-tree-sitter Version: 0.26.0 Release: 1%{?dist} Summary: Python bindings to the Tree-sitter parsing library License: MIT URL: https://github.com/tree-sitter/py-tree-sitter Source0: %{pypi_source tree_sitter} BuildRequires: python3-devel BuildRequires: gcc BuildRequires: pkgconfig(tree-sitter) BuildRequires: python3-pytest # Grammars for the test suite BuildRequires: pkgconfig(tree-sitter-html) BuildRequires: pkgconfig(tree-sitter-javascript) BuildRequires: pkgconfig(tree-sitter-json) BuildRequires: pkgconfig(tree-sitter-python) BuildRequires: pkgconfig(tree-sitter-rust) %global _description %{expand: Python bindings to Tree-sitter, an incremental parsing library. With a grammar package such as tree-sitter-javascript, they parse source code into concrete syntax trees, edit and re-parse them, walk them with cursors and run pattern queries over them.} %description %{_description} %package -n python3-tree-sitter Summary: %{summary} %description -n python3-tree-sitter %{_description} %prep %autosetup -n tree_sitter-%{version} # Link Fedora's libtree-sitter instead of compiling the bundled copy; the # bindings use only the public API (tree_sitter/api.h). rm -r tree_sitter/core sed -i \ -e '/"tree_sitter\/core\/lib\/src\/lib.c",/d' \ -e '/"tree_sitter\/core\/lib\/include",/d' \ -e '/"tree_sitter\/core\/lib\/src",/d' \ -e 's/^\(\s*\)name="tree_sitter._binding",/&\n\1libraries=["tree-sitter"],/' \ -e '/("TREE_SITTER_HIDE_SYMBOLS", None),/d' \ setup.py grep -q 'libraries=\["tree-sitter"\]' setup.py ! grep -q core/lib setup.py %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %install %pyproject_install %pyproject_save_files -l tree_sitter %check %pyproject_check_import # The tests import grammar modules from PyPI (tree_sitter_javascript and # others). Stand in for them with Fedora's grammar libraries. for g in html javascript json python rust; do mkdir -p _grammars/tree_sitter_$g cat > _grammars/tree_sitter_$g/__init__.py < - 0.26.0-1 - Initial package