Skip to content

bug: tree-sitter-python cannot be imported on free-threaded 3.14 #337

Description

@ngoldbaum

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-python

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.26.9

Describe the bug

Free-threaded Python 3.14 doesn't support the Python limited API, so this likely has something to do with that.

If I install tree-sitter-python from pypi using a free-threaded 3.14 interpreter, the build configuration incorrectly generates an abi3 wheel, which is unusable on free-threaded 3.14:

○  pip install tree-sitter-python
Collecting tree-sitter-python
  Downloading tree_sitter_python-0.25.0.tar.gz (159 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: tree-sitter-python
  Building wheel for tree-sitter-python (pyproject.toml) ... done
  Created wheel for tree-sitter-python: filename=tree_sitter_python-0.25.0-cp310-abi3-macosx_26_0_arm64.whl size=74095 sha256=d25603da12aaafb35c5657499a223f07f271041ebb0b3ae1bc8fb0965b1d0f99
  Stored in directory: /Users/goldbaum/Library/Caches/pip/wheels/ca/73/dd/85ca10aa6c6288fff58c4d8da6840c8176c858507c8289c6dc
Successfully built tree-sitter-python
Installing collected packages: tree-sitter-python
Successfully installed tree-sitter-python-0.25.0

Despite the ABI tag on the wheel that gets build, the actual .so extension in the wheel does have a free-threaded ABI tag, but it doesn't import.

○  ls /Users/goldbaum/.pyenv/versions/3.14.5t/lib/python3.14t/site-packages/tree_sitter_python
__init__.py                     binding.c
__init__.pyi                    py.typed
__pycache__                     queries
_binding.cpython-314t-darwin.so

Steps To Reproduce/Bad Parse Tree

<set up a free-threaded 3.14t environment>
pip install tree-sitter-python
python -c "import tree_sitter_python"
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import tree_sitter_python
  File "/Users/goldbaum/.pyenv/versions/3.14.5t/lib/python3.14t/site-packages/tree_sitter_python/__init__.py", line 5, in <module>
    from ._binding import language
ImportError: dlopen(/Users/goldbaum/.pyenv/versions/3.14.5t/lib/python3.14t/site-packages/tree_sitter_python/_binding.cpython-314t-darwin.so, 0x0002): symbol not found in flat namespace '_tree_sitter_python_external_scanner_create'

Expected Behavior/Parse Tree

Successful import.

Repro

import tree_sitter_python

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions