Skip to main content

Pre-compiled tree-sitter parsers for 305 programming languages with a unified process() API for parsing, analysis, and intelligent code chunking.

Project description

tree-sitter-language-pack — Python

Banner

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

Installation

pip install tree-sitter-language-pack
uv add tree-sitter-language-pack

Quick Start

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

Language Detection

  • detect_language(path) -- detect language from file path
  • detect_language_from_extension(ext) -- detect language from a bare file extension
  • detect_language_from_path(path) -- detect language from a file path
  • detect_language_from_content(content) -- detect language from shebang line
  • extension_ambiguity(ext) -- check if an extension is ambiguous (returns assigned language + alternatives)

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

Syntax Highlighting Queries

  • get_highlights_query(language) -- get bundled highlights.scm query for a language
  • get_injections_query(language) -- get bundled injections.scm query
  • get_locals_query(language) -- get bundled locals.scm query

For full documentation, see kreuzberg.dev.

License

MIT -- see LICENSE for details.


Part of tree-sitter-language-pack -- A comprehensive collection of tree-sitter language parsers with polyglot bindings.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_language_pack-1.6.1-cp310-abi3-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_language_pack-1.6.1-cp310-abi3-manylinux_2_34_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

tree_sitter_language_pack-1.6.1-cp310-abi3-manylinux_2_34_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ ARM64

tree_sitter_language_pack-1.6.1-cp310-abi3-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file tree_sitter_language_pack-1.6.1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_language_pack-1.6.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 34d9bd0e6cadf1a2c6fd7e73eb9dd490eca703263ece93c63cfdda7b34520d77
MD5 2ffa1f64fd8b5f9d19b405a916895279
BLAKE2b-256 4843bd347295026a0ab822c36eb621be21823bb31cb80267e2d5e87b1f0bcb00

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_language_pack-1.6.1-cp310-abi3-win_amd64.whl:

Publisher: publish.yaml on kreuzberg-dev/tree-sitter-language-pack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_language_pack-1.6.1-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_language_pack-1.6.1-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d414bc34186ccc6f68b97699e06c76338725451a31a98a71a0822d1583aef66f
MD5 0218ee7b03d1f781a8878456e62976d5
BLAKE2b-256 806a482b36d4030492e71d1235902487698e1d53a33d4ae2896103a0c280e9af

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_language_pack-1.6.1-cp310-abi3-manylinux_2_34_x86_64.whl:

Publisher: publish.yaml on kreuzberg-dev/tree-sitter-language-pack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_language_pack-1.6.1-cp310-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_language_pack-1.6.1-cp310-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 8354813b8666af395a724d2323bd3e6fd1148151b253b63045de13cdf7f3a413
MD5 61e2f15657080541ce484638383e2b59
BLAKE2b-256 7c794a81fbd4ff96598fa7867ebbed3cd0fe8ebdec3a3f39725ffcc6cc9a1ee3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_language_pack-1.6.1-cp310-abi3-manylinux_2_34_aarch64.whl:

Publisher: publish.yaml on kreuzberg-dev/tree-sitter-language-pack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_language_pack-1.6.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_language_pack-1.6.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c1e61c1174ffcbb492ae76c95b68fb58930a0f776f5fe3fae5b67e07d9ae770
MD5 f752d2dadeefc83887eda03c7dd89c10
BLAKE2b-256 8c5ab479def27c195ce3c0b63e9103b96207b0650ae77773719757ca24d56f72

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_language_pack-1.6.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yaml on kreuzberg-dev/tree-sitter-language-pack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page