Metadata-Version: 2.4
Name: tree-sitter-language-pack
Version: 1.0.0rc8
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Typing :: Typed
Requires-Dist: tree-sitter>=0.24
Summary: Pre-compiled tree-sitter parsers for 170+ programming languages with a unified process() API for parsing, analysis, and intelligent code chunking.
Keywords: ast,code-analysis,code-intelligence,kreuzberg,language-pack,parser,syntax,tree-sitter
License-Expression: MIT OR Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/kreuzberg-dev/tree-sitter-language-pack
Project-URL: Issues, https://github.com/kreuzberg-dev/tree-sitter-language-pack/issues
Project-URL: Repository, https://github.com/kreuzberg-dev/tree-sitter-language-pack

<!-- Generated by scripts/generate_readme.py. DO NOT EDIT. -->

# tree-sitter-language-pack — Python

<div align="center" style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0;">
  <!-- Language Bindings -->  <a href="https://crates.io/crates/tree-sitter-language-pack">
    <img src="https://img.shields.io/crates/v/tree-sitter-language-pack?label=Rust&color=007ec6" alt="Rust">
  </a>  <a href="https://pypi.org/project/tree-sitter-language-pack/">
    <img src="https://img.shields.io/pypi/v/tree-sitter-language-pack?label=Python&color=007ec6" alt="Python">
  </a>  <a href="https://www.npmjs.com/package/@kreuzberg/tree-sitter-language-pack">
    <img src="https://img.shields.io/npm/v/@kreuzberg/tree-sitter-language-pack?label=Node.js&color=007ec6" alt="Node">
  </a>  <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/tree/main/packages/go/v1">
    <img src="https://img.shields.io/github/v/tag/kreuzberg-dev/tree-sitter-language-pack?label=Go&color=007ec6" alt="Go">
  </a>  <a href="https://central.sonatype.com/artifact/dev.kreuzberg/tree-sitter-language-pack">
    <img src="https://img.shields.io/maven-central/v/dev.kreuzberg/tree-sitter-language-pack?label=Java&color=007ec6" alt="Java">
  </a>  <a href="https://hex.pm/packages/tree_sitter_language_pack">
    <img src="https://img.shields.io/hexpm/v/tree_sitter_language_pack?label=Elixir&color=007ec6" alt="Elixir">
  </a>  <a href="https://rubygems.org/gems/tree_sitter_language_pack">
    <img src="https://img.shields.io/gem/v/tree_sitter_language_pack?label=Ruby&color=007ec6" alt="Ruby">
  </a>  <a href="https://www.npmjs.com/package/@kreuzberg/tree-sitter-language-pack-wasm">
    <img src="https://img.shields.io/npm/v/@kreuzberg/tree-sitter-language-pack-wasm?label=WASM&color=007ec6" alt="Wasm">
  </a>  <a href="https://packagist.org/packages/kreuzberg/tree-sitter-language-pack">
    <img src="https://img.shields.io/packagist/v/kreuzberg/tree-sitter-language-pack?label=PHP&color=007ec6" alt="Php">
  </a>  <a href="https://www.nuget.org/packages/TreeSitterLanguagePack">
    <img src="https://img.shields.io/nuget/v/TreeSitterLanguagePack?label=C%23&color=007ec6" alt="Csharp">
  </a>
  <!-- Project Info -->
  <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/actions">
    <img src="https://img.shields.io/github/actions/workflow/status/kreuzberg-dev/tree-sitter-language-pack/ci-rust.yaml?branch=main&label=CI" alt="CI">
  </a>
  <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/blob/main/LICENSE">
    <img src="https://img.shields.io/badge/License-MIT%20%7C%20Apache--2.0-blue" alt="License">
  </a>
  <a href="https://github.com/kreuzberg-dev/homebrew-tap">
    <img src="https://img.shields.io/badge/homebrew-ts--pack-FBB040?logo=homebrew" alt="Homebrew">
  </a>
  <a href="https://docs.rs/tree-sitter-language-pack">
    <img src="https://img.shields.io/badge/docs-crates.io-blue" alt="Docs">
  </a>
</div>

<div align="center">
  <a href="https://discord.gg/xt9WY3GnKR">
    <img height="22" src="https://img.shields.io/badge/Discord-Join%20our%20community-7289da?logo=discord&logoColor=white" alt="Discord">
  </a>
</div>

Python bindings for tree-sitter-language-pack, providing access to 170+ pre-compiled tree-sitter parsers with on-demand downloads.

## Installation

```sh
pip install tree-sitter-language-pack
```

```sh
uv add tree-sitter-language-pack
```

## Quick Start

```python
from tree_sitter_language_pack import init, download, get_language, get_parser, available_languages

# Optional: Pre-download specific languages for offline use
init(["python", "javascript", "rust"])

# Get a language (auto-downloads if not cached)
language = get_language("python")

# Get a pre-configured parser (auto-downloads if needed)
parser = get_parser("python")
tree = parser.parse(b"def hello(): pass")
print(tree.root_node.sexp())

# List all available languages
for lang in available_languages():
    print(lang)

from tree_sitter_language_pack import process, ProcessConfig

# Extract file intelligence (auto-downloads language if needed)
result = process("def hello(): pass", ProcessConfig(language="python"))
print(f"Functions: {len(result['structure'])}")

# Pre-download languages for offline use
download(["python", "javascript"])

# With chunking
result = process(source, ProcessConfig(language="python", chunk_max_size=1000, comments=True))
print(f"Chunks: {len(result['chunks'])}")
```

## API Reference

### Language Discovery

- `available_languages()` -- list all supported language names
- `has_language(name)` -- check if a language is available
- `language_count()` -- total number of supported languages

### Parsing

- `get_parser(name)` / `parse_string(source, language)` -- parse source code into a syntax tree

### Download API

- `init(languages)` -- pre-download specific languages for offline use
- `download(languages)` -- download parsers on demand

### Intelligence

- `process(source, config)` -- extract structured analysis (functions, classes, imports, comments, chunks) from source code

For detailed API documentation, see the [Python package](https://github.com/kreuzberg-dev/tree-sitter-language-pack/tree/main/crates/ts-pack-python).

## License

MIT OR Apache-2.0 -- see [LICENSE](https://github.com/kreuzberg-dev/tree-sitter-language-pack/blob/main/LICENSE) for details.

---

Part of [tree-sitter-language-pack](https://github.com/kreuzberg-dev/tree-sitter-language-pack) -- A comprehensive collection of tree-sitter language parsers with polyglot bindings.

