Registry / serialization / tree-sitter-language-pack

tree-sitter-language-pack

JSON →
library1.15.8pypypi✓ verified 25d ago

tree-sitter-language-pack is a Python library providing pre-compiled Tree-sitter parsers for over 300 programming languages. It offers a unified `process()` API for efficient parsing, advanced code analysis, and intelligent code chunking. The library is actively maintained with frequent releases, typically introducing new language grammars and API enhancements.

pip install tree-sitter-language-pack
INSTALL
IMPORT
SIG · TREE-SITTER-LANGUA
T
tree-sitter-language-pack
serializationpythonv1.15.8
Install
1.9s avg
Import
95ms
Disk
58MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.15.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.076s · 26MB
58MB installed
● package 58MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

process
from tree_sitter_language_pack import process, ProcessConfig
The `process` function with `ProcessConfig` is the recommended unified API for comprehensive parsing and analysis.
get_language
from tree_sitter_language_pack import get_language, get_parser
These functions provide direct access to `tree-sitter.Language` and `tree-sitter.Parser` objects, primarily for lower-level interaction if `process()` is not sufficient.

This quickstart demonstrates the core `process()` API to extract structured intelligence from source code, including functions, diagnostics, and comments. It also shows how to use AST-aware chunking for breaking down larger code blocks. The library automatically downloads necessary language parsers on demand.

from tree_sitter_language_pack import process, ProcessConfig import os source_code = """ def hello(): # This is a comment print("Hello, World!") class MyClass: def __init__(self): pass """ # Process source code for intelligence extraction (auto-downloads language if needed) result = process(source_code, ProcessConfig(language="python")) print(f"Functions found: {len(result.get('structure', []))}") print(f"Diagnostics: {result.get('diagnostics', [])}") print(f"Comments: {result.get('comments', [])}") # Example with AST-aware chunking chunked_result = process( source_code, ProcessConfig(language="python", chunk_max_size=50, comments=True) ) print(f"Chunks found: {len(chunked_result.get('chunks', []))}")
Debug
Known issues
gotchaPrior to v1.4.2, installation documentation, especially for the CLI (`ts-pack-cli`), contained incorrect package names and references, leading to potential installation issues or confusion.
fix
Ensure you are using the correct package name `tree-sitter-language-pack` for Python and refer to the latest documentation for CLI installation (`cargo install ts-pack-cli` or `brew install kreuzberg-dev/tap/ts-pack`).
affects: <1.4.2
gotchaVersions prior to v1.3.3 experienced issues with dynamic parser loading and `c_symbol` overrides for specific languages (e.g., C#, VB, Embedded Template, Nushell), potentially causing runtime errors.
fix
Upgrade to v1.3.3 or newer to resolve issues with dynamic loading and `c_symbol` overrides for affected languages.
affects: <1.3.3
gotchaWhile direct access to `tree-sitter.Language` and `tree-sitter.Parser` objects via `get_language()` and `get_parser()` is available, the `process()` function with `ProcessConfig` is the recommended and unified API across all bindings for comprehensive code intelligence, including parsing, analysis, and chunking.
fix
Prefer using the `process()` API with `ProcessConfig` for most code intelligence tasks to leverage the full capabilities and consistent interface of the library.
affects: All versions
gotchatree-sitter-language-pack aims to simplify Tree-sitter usage by bundling grammars. However, if integrating with other raw `tree-sitter` libraries or manually compiled grammars, be aware that the underlying `tree-sitter` ecosystem can have complex versioning and compilation requirements that might lead to conflicts or unexpected behavior.
fix
Rely primarily on `tree-sitter-language-pack` for all your grammar needs to maintain consistency. If interoperability is required, carefully manage `tree-sitter` versions and compilation flags.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tree_sitter_language_pack'
The top-level module to import from is `tree_sitter_languages`, not the name of the pip package `tree-sitter-language-pack`.
fix
Use `from tree_sitter_languages import get_language, Language` to import the necessary components.
KeyError: 'Language not found: <your_language_string>'
The requested language string does not exactly match one of the supported language identifiers recognized by the library.
fix
Check the available languages using `tree_sitter_languages.get_available_languages()` and use the exact string provided in the list.
_ffi.BackendError: The tree-sitter C library could not be loaded.
The underlying Tree-sitter C library (or its Python bindings, provided by the `tree-sitter` package) could not be loaded, often due to missing shared library files or environment issues.
fix
Ensure the `tree-sitter` package is correctly installed and its C dependencies are met; on some systems, this might require installing development packages (e.g., `libtree-sitter-dev`) or reinstalling `pip install tree-sitter tree-sitter-language-pack`.
TypeError: argument 'language': 'str' object cannot be converted to 'tree_sitter_languages.Language' type
The `process()` function expects a `Language` object (obtained via `get_language()`), not a plain string representing the language name.
fix
First, get the `Language` object using `get_language()` and then pass it to the `process()` function: `from tree_sitter_languages import get_language, process; code_string = 'print("hello")'; python_language = get_language('python'); result = process(code_string, python_language)`.
Upgrade
Version history
1.15.8latest on PyPI · released Aug 23, 2026
Audit
Dependencies
pythonrequiredRequired for Python bindings.
Agent activity
14 hits · last 30 days
node
10
OpenAI (training)
1
Resources
tree-sitter-language-pack — pip install tree-sitter-language-pack · libregistry