Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to bundle TreeSitter bindings #1092

Open
williballenthin opened this issue Jul 6, 2022 · 1 comment
Open

how to bundle TreeSitter bindings #1092

williballenthin opened this issue Jul 6, 2022 · 1 comment

Comments

@williballenthin
Copy link
Collaborator

williballenthin commented Jul 6, 2022

Originally posted by @williballenthin in #1080 (comment)

ideally, we want to be able to install capa simply by doing pip install flare-capa and/or fetching the standalone executable from github (generated via pyinstaller). this means our dependencies should live within the python ecosystem.

there is a supported TreeSitter library for Python; however, it doesn't include the bindings for each language we parse with TreeSitter. these bindings must be compiled into shared objects and distributed for use with the TreeSitter library.

we need to figure out how to distribute the shared object code with capa so that it "just works".

@williballenthin
Copy link
Collaborator Author

one strategy:

Rust has good TreeSitter library support and can statically link language bindings. Rust also has great Python binding support via PyO3, which is how we distribute our implementation of FLIRT to all supported platforms (windows/mac/linux * 32/64bits).

we could build a Python package implemented as a native library via Rust+PyO3 and distributed on PyPI that embeds the TreeSitter library and all bindings.

pro:

con:

  • have to write code to wrap the TS APIs that we want
  • yet another github repository to maintain (though it can easily have CI/CD, too)

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

No branches or pull requests

1 participant