Skip to content

fix(python): require tree-sitter>=0.25 for the ABI 15 grammars - #57

Open
PYDuquesnoy wants to merge 1 commit into
intersystems:mainfrom
intersystems-ib:fix/python-tree-sitter-floor
Open

PYDuquesnoy wants to merge 1 commit into
intersystems:mainfrom
intersystems-ib:fix/python-tree-sitter-floor

Conversation

@PYDuquesnoy

Copy link
Copy Markdown

Summary

The Python distribution's only tree-sitter requirement is the optional extra core = ["tree-sitter~=0.23"]. ~=0.23 means >=0.23, ==0.*, so it admits 0.23.x and 0.24.x, but every generated parser is ABI 15 (#define LANGUAGE_VERSION 15 in all five src/parser.c), and py-tree-sitter only accepts ABI 15 from 0.25.

Verified with the released tree-sitter-objectscript==1.9.22 wheel on Python 3.12:

tree-sitter Language(language_objectscript_udl()) Parser(language)
0.23.2 constructs ValueError: Incompatible Language version 15. Must be between 13 and 14
0.24.0 constructs same error
0.25.2 ok, abi_version == 15 ok, parses
0.26.0 ok, abi_version == 15 ok, parses

So an environment that already has 0.23/0.24 installed satisfies the extra and fails at the first parse rather than at install time.

Changes

  • pyproject.toml: core = ["tree-sitter>=0.25,<1"]
  • README.md: the install line pins "tree-sitter>=0.25"
  • bindings/python/tests/test_binding.py: new test asserting each of the three grammars reports abi_version == 15 (the attribute only exists from py-tree-sitter 0.25, so the test doubles as a guard on the floor)

Not touched, for the maintainers to decide: making tree-sitter a regular dependency instead of an extra (the wheel is unusable from Python without it), and the pyproject.toml version (1.9.20 here vs 1.9.22 on PyPI).

Verification

# binding tests against the released wheel (tree-sitter 0.25.2)
python -m pytest -q bindings/python/tests/test_binding.py      # 7 passed
# floor check
uv venv /tmp/ts --python 3.12
uv pip install --python /tmp/ts/bin/python "tree-sitter==0.24.0" "tree-sitter-objectscript==1.9.22"
/tmp/ts/bin/python -c "import tree_sitter as ts, tree_sitter_objectscript_udl as u; ts.Parser(ts.Language(u.language_objectscript_udl()))"
# -> ValueError: Incompatible Language version 15. Must be between 13 and 14
uv pip install --python /tmp/ts/bin/python "tree-sitter>=0.25,<1"   # -> 0.26.0, parses, abi_version 15

Fixes #56.

🤖 Generated with Claude Code

The `core` extra pinned `tree-sitter~=0.23`, which admits 0.23.x and 0.24.x.
All five generated parsers declare LANGUAGE_VERSION 15, and py-tree-sitter
only accepts ABI 15 from 0.25: on 0.23.2 and 0.24.0 the Language object
constructs but `Parser(language)` raises
"ValueError: Incompatible Language version 15. Must be between 13 and 14".

- pyproject: core = ["tree-sitter>=0.25,<1"]
- README: install line pins "tree-sitter>=0.25"
- bindings/python/tests: assert every grammar reports abi_version == 15
  (the attribute itself only exists from 0.25, so the test also guards
  the floor)

Fixes intersystems#56

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python package: raise tree-sitter floor to >=0.25 (grammar is ABI 15; ~=0.23 admits 0.23/0.24, which cannot load it)

1 participant