py-tree-sitter icon indicating copy to clipboard operation
py-tree-sitter copied to clipboard

Distribute binary wheels with all languages?

Open grantjenks opened this issue 3 years ago • 4 comments

I've used GitHub Actions in the past to distribute binary wheels. Would you be open to do that with py-tree-sitter?

Also, the current workflow for adding language support is hard to integrate with CI systems. For the sake of developer productivity, would it be possible to simply distribute all languages with the package by default?

grantjenks avatar Jan 18 '22 07:01 grantjenks

I made this for the same purpose but just for the python language. Note this is not a binary wheel, but one that will compile tree-sitter-python on install. Would love to make it more generic and move it to this repo tho

https://github.com/NorthIsUp/tree-sitter-python-language

NorthIsUp avatar Mar 15 '22 21:03 NorthIsUp

py-tree-sitter-languages

FYI I created https://github.com/grantjenks/py-tree-sitter-languages to distribute binary Python wheels with all tree-sitter languages supported.

Install

$ pip install tree_sitter_languages

Source installs are not supported. To see how the binary wheels are built, look at:

  1. setup.py — Python package setup.
  2. build.sh — Shell script to download support for all languages.
  3. build.py — Python script to build support for all languages.
  4. .github/workflows/release.yml — GitHub action to invoke cibuildwheel and release to PyPI.

Usage

from tree_sitter_languages import get_language, get_parser

language = get_language('python')
parser = get_parser('python')

That's the whole API!

Refer to py-tree-sitter for the language and parser API. Notice the Language.build_library(...) step can be skipped! The binary wheel includes the language binary.

grantjenks avatar May 16 '22 18:05 grantjenks

I have a local branch that compiles languages directly into our library, I'm planning to put more work into that.

With either approach, you might want to be mindful of the parser licenses.

lunixbochs avatar May 16 '22 18:05 lunixbochs

Good point about licenses. I checked them this morning and included a list at the bottom of the README: https://github.com/grantjenks/py-tree-sitter-languages#license

grantjenks avatar May 17 '22 15:05 grantjenks

Parsers can now easily build wheels themselves with the updated bindings in https://github.com/tree-sitter/tree-sitter/commit/9e5bf6591fbf69f7cf79d178e4bcae98408bae40.

ObserverOfTime avatar Feb 26 '24 12:02 ObserverOfTime