Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/autosoft-dev/tree-sitter-docker
A docker image with all the necessary libaries you need to build tree-sitter .so files
https://github.com/autosoft-dev/tree-sitter-docker
Last synced: 2 days ago
JSON representation
A docker image with all the necessary libaries you need to build tree-sitter .so files
- Host: GitHub
- URL: https://github.com/autosoft-dev/tree-sitter-docker
- Owner: autosoft-dev
- Created: 2020-02-25T12:46:21.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-22T09:17:28.000Z (over 4 years ago)
- Last Synced: 2024-11-05T19:42:32.932Z (4 days ago)
- Language: Dockerfile
- Size: 2.93 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tree-sitter-docker
A docker image with all the necessary libaries you need to build tree-sitter .so files### Pre-text
We at [CodistAI](https://codist-ai.com/) use [tree-sitter](http://tree-sitter.github.io/tree-sitter/) a lot.
Now, it depends on [clang](https://llvm.org/) to be able to function properly. When one of our team-mate used Ubuntu, they found it
hard to compile some of the tree-sitter libaries (Following the instructions [here](https://github.com/tree-sitter/py-tree-sitter)) So, this little Dockerfile will let you install all the needed dependencies and then bring you right
inside a iPython prompt where you can run the example code and build the libraries.### Building the docker image
Git clone this repo and then `cd` to it.
Then use the following command to build the image
```
docker build -t ubuntu-clang-image .
```### Using the image
- Go to any directory. (For the sake of this example we assume that you created a directory tree like `docker_llvm/tree_sitter_libs` and you are the `docker_llvm` level)
- Run
```
docker run -it -v $PWD/tree_sitter_libs:/tree_sitter_libs --name ubuntu_clang ubuntu-clang-image
```- You will be right in the middle of an iPython prompt.
- You will need to clone some of the tree-sitter libs. So let's say something like this
```
>>> !git clone https://github.com/tree-sitter/tree-sitter-python
>>> !git clone https://github.com/tree-sitter/tree-sitter-php
```- Once done, you should be able to use the following code to build the .so file
```
from tree_sitter import Language, ParserLanguage.build_library(
# Store the library in the `tree_sitter_libs` directory
'tree_sitter_libs/my-languages.so',# Include one or more languages
[
'tree-sitter-php',
'tree-sitter-python'
]
)
```- Voila! you will have your .so in the `tree_sitter_libs` directory, ready to be used.