[packages/tree-sitter-markdown] - added python3 binding
qboosh
qboosh at pld-linux.org
Mon Jan 19 21:06:56 CET 2026
commit e0e65f57b52e07f774d095e47cda555875b20c02
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Mon Jan 19 21:06:52 2026 +0100
- added python3 binding
tree-sitter-markdown-python.patch | 29 ++++++++++++++++++++++++
tree-sitter-markdown.spec | 46 +++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+)
---
diff --git a/tree-sitter-markdown.spec b/tree-sitter-markdown.spec
index b58e039..97d9317 100644
--- a/tree-sitter-markdown.spec
+++ b/tree-sitter-markdown.spec
@@ -1,3 +1,7 @@
+#
+# Conditional build:
+%bcond_without python3 # Python 3.x binding
+
Summary: Markdown grammar for tree-sitter
Summary(pl.UTF-8): Gramatyka formatu Markdown dla tree-sittera
Name: tree-sitter-markdown
@@ -9,9 +13,15 @@ Group: Libraries
Source0: https://github.com/tree-sitter-grammars/tree-sitter-markdown/archive/v%{version}/%{name}-%{version}.tar.gz
# Source0-md5: cbc71aea4dab8d70ad59957d54c08446
Patch0: %{name}-typo.patch
+Patch1: %{name}-python.patch
URL: https://github.com/tree-sitter-grammars/tree-sitter-markdown
# c11
BuildRequires: gcc >= 6:4.7
+%if %{with python3}
+BuildRequires: python3-devel >= 1:3.10
+BuildRequires: python3-setuptools
+BuildRequires: python3-wheel
+%endif
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%define soname_ver 15.0
@@ -58,9 +68,22 @@ Markdown parser for Neovim.
%description -n neovim-parser-markdown -l pl.UTF-8
Analizator składni formatu Markdown Lua dla Neovima.
+%package -n python3-tree-sitter-markdown
+Summary: Lua parser for Python
+Summary(pl.UTF-8): Analizator składni formatu Markdown dla Pythona
+Group: Libraries/Python
+Requires: python3-tree-sitter >= 0.24
+
+%description -n python3-tree-sitter-markdown
+Lua parser for Python.
+
+%description -n python3-tree-sitter-markdown -l pl.UTF-8
+Analizator składni formatu Markdown dla Pythona.
+
%prep
%setup -q
%patch -P0 -p1
+%patch -P1 -p1
%build
%{__make} \
@@ -72,6 +95,10 @@ Analizator składni formatu Markdown Lua dla Neovima.
CFLAGS="%{rpmcppflags} %{rpmcflags}" \
LDFLAGS="%{rpmldflags}"
+%if %{with python3}
+%py3_build
+%endif
+
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_libdir}/nvim/parser
@@ -92,6 +119,13 @@ install -d $RPM_BUILD_ROOT%{_libdir}/nvim/parser
# redundant symlinks
%{__rm} $RPM_BUILD_ROOT%{_libdir}/libtree-sitter-markdown*.so.15
+%if %{with python3}
+%py3_install
+
+%{__rm} $RPM_BUILD_ROOT%{py3_sitedir}/tree_sitter_markdown/*.c
+
+%endif
+
%clean
rm -rf $RPM_BUILD_ROOT
@@ -127,3 +161,15 @@ rm -rf $RPM_BUILD_ROOT
%defattr(644,root,root,755)
%{_libdir}/nvim/parser/markdown.so
%{_libdir}/nvim/parser/markdown_inline.so
+
+%if %{with python3}
+%files -n python3-tree-sitter-markdown
+%defattr(644,root,root,755)
+%dir %{py3_sitedir}/tree_sitter_markdown
+%{py3_sitedir}/tree_sitter_markdown/_binding.abi3.so
+%{py3_sitedir}/tree_sitter_markdown/__init__.py
+%{py3_sitedir}/tree_sitter_markdown/__init__.pyi
+%{py3_sitedir}/tree_sitter_markdown/py.typed
+%{py3_sitedir}/tree_sitter_markdown/__pycache__
+%{py3_sitedir}/tree_sitter_markdown-%{version}-py*.egg-info
+%endif
diff --git a/tree-sitter-markdown-python.patch b/tree-sitter-markdown-python.patch
new file mode 100644
index 0000000..fbc18a5
--- /dev/null
+++ b/tree-sitter-markdown-python.patch
@@ -0,0 +1,29 @@
+--- tree-sitter-markdown-0.5.2/setup.py.orig 2026-01-11 11:44:35.000000000 +0100
++++ tree-sitter-markdown-0.5.2/setup.py 2026-01-19 21:03:22.691398454 +0100
+@@ -22,8 +22,8 @@ class BuildExt(build_ext):
+ ext.extra_compile_args = ["-std=c11", "-fvisibility=hidden"]
+ else:
+ ext.extra_compile_args = ["/std:c11", "/utf-8"]
+- if path.exists("src/scanner.c"):
+- ext.sources.append("src/scanner.c")
++ if path.exists("tree-sitter-markdown/src/scanner.c"):
++ ext.sources.append("tree-sitter-markdown/src/scanner.c")
+ if ext.py_limited_api:
+ ext.define_macros.append(("Py_LIMITED_API", "0x030A0000"))
+ super().build_extension(ext)
+@@ -57,13 +57,13 @@ setup(
+ name="_binding",
+ sources=[
+ "bindings/python/tree_sitter_markdown/binding.c",
+- "src/parser.c",
++ "tree-sitter-markdown/src/parser.c",
+ ],
+ define_macros=[
+ ("PY_SSIZE_T_CLEAN", None),
+ ("TREE_SITTER_HIDE_SYMBOLS", None),
+ ],
+- include_dirs=["src"],
++ include_dirs=["tree-sitter-markdown/src"],
+ py_limited_api=not get_config_var("Py_GIL_DISABLED"),
+ )
+ ],
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/tree-sitter-markdown.git/commitdiff/e0e65f57b52e07f774d095e47cda555875b20c02
More information about the pld-cvs-commit
mailing list