Isopod / tree-sitter-pascal

Treesitter grammar for Pascal and its dialects (Delphi, Freepascal)
MIT License
32 stars 11 forks source link

Update language bindings to avoid py-tree-sitter "removed in v0.22.0" (next version!) warning #3

Open vintagedave opened 2 months ago

vintagedave commented 2 months ago

Hello,

First - I love that you are providing a treesitter grammar for Pascal and Delphi. Thankyou.

Using it from Python, I found I needed to use the build from source setup, ie cloning and then using Language.build_library to use my system's inbuilt C compiler to build the dynamic library.

The py-tree-sitter project warns that treesitter libraries need to update their bindings, and that this method won't be available in 0.22 -- which is the next version!

Would it be possible to update the bindings to suit the upcoming API change please?

(It's possible you don't support Python -- this is a treesitter grammar repo, not a Python repo :) I can have a go myself if so. I have zero idea what's involved in updating to match the new requirement. Figured it's worth filing an issue and asking here first!)

Isopod commented 2 months ago

Hi,

thanks for informing me of this. I did not know I also had to ship the stuff in bindings/. Can you try this #4 branch? Does that fix it?

vintagedave commented 2 months ago

Thankyou! I am not quite sure how to best test it. Usually this would be a Python package, but trying it by putting it in a folder, I have code like:

import treesitterpascal.bindings.python.tree_sitter_pascal as pascal
from tree_sitter import Language, Parser

PASCAL_LANGUAGE = Language(pascal.language(), "pascal")

and that gives, ModuleNotFoundError: No module named 'treesitterpascal.bindings.python.tree_sitter_pascal._binding'

I see the __init__.py file is referring to ".binding", but I don't see where that's defined. Nor, I'm afraid, do I know enough about Python packages to quite understand the structure. I do see __init__.pyi (with a I in the extension) has a language defined.

When I look at the Python treesitter bindings for Python, I see an extra folder: https://github.com/tree-sitter/tree-sitter-python/blob/master/bindings/python/build/lib/tree_sitter_python/__init__.py

Isopod commented 2 months ago

Unfortunately I don't know much about Python, either. I found a comment that says you can install a package with pip from a URL. I don't know if it's possible to specify a branch, but perhaps it also works with a local path?

I don't see any bindings/python/build directory in my local folder. Even after re-running tree-sitter generate and tree-sitter build it is not being generated.

ObserverOfTime commented 2 months ago

I don't know if it's possible to specify a branch, but perhaps it also works with a local path?

pip install git+https://github.com/Isopod/tree-sitter-pascal@language-bindings

I don't see any bindings/python/build directory in my local folder.

That directory should not be there.

vintagedave commented 1 month ago

I have not succeeded in getting this to work yet, but as noted I'm not an expert here. Mostly commenting just to let you know I have not forgotten the issue, and have continued to spend a some time here and there testing it.

vintagedave commented 4 days ago

@Isopod Would it be possible to email you about something related to this repo, please? I can't find contact details for you on the repo. If you email me, my email address is my username at gmail.com.

Thankyou!