Skip to content

Commit 329919b

Browse files
feat: add version string
1 parent 2a94c01 commit 329919b

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[build-system]
2-
requires = ["setuptools>=43"]
3-
build-backend = "setuptools.build_meta"
4-
51
[project]
62
name = "tree-sitter"
73
version = "0.25.1"
@@ -34,13 +30,17 @@ email = "[email protected]"
3430
[project.optional-dependencies]
3531
docs = ["sphinx~=8.1", "sphinx-book-theme"]
3632
tests = [
37-
"tree-sitter-html>=0.23.2",
38-
"tree-sitter-javascript>=0.23.1",
39-
"tree-sitter-json>=0.24.8",
40-
"tree-sitter-python>=0.23.6",
41-
"tree-sitter-rust>=0.23.2",
33+
"tree-sitter-html==0.23.2",
34+
"tree-sitter-javascript==0.25.0",
35+
"tree-sitter-json==0.24.8",
36+
"tree-sitter-python==0.25.0",
37+
"tree-sitter-rust==0.24.0",
4238
]
4339

40+
[build-system]
41+
requires = ["setuptools>=43"]
42+
build-backend = "setuptools.build_meta"
43+
4444
[tool.ruff]
4545
target-version = "py310"
4646
line-length = 100

setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
from setuptools import Extension, setup # type: ignore
44
from setuptools.command.build_ext import build_ext
55

6+
with open("pyproject.toml") as f:
7+
next(f) # skip [project]
8+
next(f) # skip name = "tree-sitter"
9+
version = next(f).replace("version = ", "", 1)
10+
611

712
class BuildExt(build_ext):
813
def build_extension(self, ext: Extension):
@@ -57,6 +62,7 @@ def build_extension(self, ext: Extension):
5762
("_DEFAULT_SOURCE", None),
5863
("PY_SSIZE_T_CLEAN", None),
5964
("TREE_SITTER_HIDE_SYMBOLS", None),
65+
("PY_TS_VERSION", version),
6066
],
6167
)
6268
],

tree_sitter/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,5 @@ class Range:
414414
LANGUAGE_VERSION: Final[int]
415415

416416
MIN_COMPATIBLE_LANGUAGE_VERSION: Final[int]
417+
418+
__version__: Final[str]

tree_sitter/binding/module.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ PyMODINIT_FUNC PyInit__binding(void) {
158158
PyModule_AddIntConstant(module, "MIN_COMPATIBLE_LANGUAGE_VERSION",
159159
TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION);
160160

161+
PyModule_AddStringConstant(module, "__version__", PY_TS_VERSION);
162+
161163
#ifdef Py_GIL_DISABLED
162164
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_USED);
163165
#endif

0 commit comments

Comments
 (0)