From 2be397af83109fb5faf0518931b0dd9ef5ab4a8f Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Wed, 8 Oct 2025 14:02:23 -0500 Subject: [PATCH] updated tree sitter version --- Cargo.toml | 2 +- bindings/python/tests/test_binding.py | 4 +-- bindings/rust/lib.rs | 2 +- setup.py | 48 +++++++++++++-------------- src/parser.c | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 86708e6..f318f57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ include = [ "queries/*", "src/*", "tree-sitter.json", - "LICENSE", + "/LICENSE", ] [lib] diff --git a/bindings/python/tests/test_binding.py b/bindings/python/tests/test_binding.py index bcb6d68..a713915 100644 --- a/bindings/python/tests/test_binding.py +++ b/bindings/python/tests/test_binding.py @@ -1,12 +1,12 @@ from unittest import TestCase -import tree_sitter +from tree_sitter import Language, Parser import tree_sitter_wit class TestLanguage(TestCase): def test_can_load_grammar(self): try: - tree_sitter.Language(tree_sitter_wit.language()) + Parser(Language(tree_sitter_wit.language())) except Exception: self.fail("Error loading Wit grammar") diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index ffcd74b..5eff20e 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -15,7 +15,7 @@ //! assert!(!tree.root_node().has_error()); //! ``` //! -//! [`Parser`]: https://docs.rs/tree-sitter/0.25.8/tree_sitter/struct.Parser.html +//! [`Parser`]: https://docs.rs/tree-sitter/0.25.10/tree_sitter/struct.Parser.html //! [tree-sitter]: https://tree-sitter.github.io/ use tree_sitter_language::LanguageFn; diff --git a/setup.py b/setup.py index 31b4d9a..181d1b6 100644 --- a/setup.py +++ b/setup.py @@ -1,31 +1,12 @@ from os import path -from platform import system from sysconfig import get_config_var from setuptools import Extension, find_packages, setup from setuptools.command.build import build +from setuptools.command.build_ext import build_ext from setuptools.command.egg_info import egg_info from wheel.bdist_wheel import bdist_wheel -sources = [ - "bindings/python/tree_sitter_wit/binding.c", - "src/parser.c", -] -if path.exists("src/scanner.c"): - sources.append("src/scanner.c") - -macros: list[tuple[str, str | None]] = [ - ("PY_SSIZE_T_CLEAN", None), - ("TREE_SITTER_HIDE_SYMBOLS", None), -] -if limited_api := not get_config_var("Py_GIL_DISABLED"): - macros.append(("Py_LIMITED_API", "0x030A0000")) - -if system() != "Windows": - cflags = ["-std=c11", "-fvisibility=hidden"] -else: - cflags = ["/std:c11", "/utf-8"] - class Build(build): def run(self): @@ -35,6 +16,19 @@ def run(self): super().run() +class BuildExt(build_ext): + def build_extension(self, ext: Extension): + if self.compiler.compiler_type != "msvc": + 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 ext.py_limited_api: + ext.define_macros.append(("Py_LIMITED_API", "0x030A0000")) + super().build_extension(ext) + + class BdistWheel(bdist_wheel): def get_tag(self): python, abi, platform = super().get_tag() @@ -61,15 +55,21 @@ def find_sources(self): ext_modules=[ Extension( name="_binding", - sources=sources, - extra_compile_args=cflags, - define_macros=macros, + sources=[ + "bindings/python/tree_sitter_wit/binding.c", + "src/parser.c", + ], + define_macros=[ + ("PY_SSIZE_T_CLEAN", None), + ("TREE_SITTER_HIDE_SYMBOLS", None), + ], include_dirs=["src"], - py_limited_api=limited_api, + py_limited_api=not get_config_var("Py_GIL_DISABLED"), ) ], cmdclass={ "build": Build, + "build_ext": BuildExt, "bdist_wheel": BdistWheel, "egg_info": EggInfo, }, diff --git a/src/parser.c b/src/parser.c index 7467f05..d03a547 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,4 +1,4 @@ -/* Automatically @generated by tree-sitter v0.25.8 */ +/* Automatically @generated by tree-sitter v0.25.10 */ #include "tree_sitter/parser.h"