Skip to main content

Pre-compiled tree-sitter parsers for 248 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 248 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_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.3.0-cp310-abi3-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_language_pack-1.3.0-cp310-abi3-manylinux_2_34_x86_64.whl (2.5 MB view details)

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

tree_sitter_language_pack-1.3.0-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.3.0-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.3.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_language_pack-1.3.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2162b161e5f08b3ea7d753862b597b8a4f2460b1d43bcb639eb8d3f69d54e0fd
MD5 81466bd1e80fb29d9c1ab816a02df174
BLAKE2b-256 20f7d5b1cab59611e38b804aad72bb874e5da2e6fd6655f4ecbdb9ad7b39a4e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_language_pack-1.3.0-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.3.0-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_language_pack-1.3.0-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 307f1a01ab4eac5e7cbb998a4b183ad5a3208a400f6521e56fc979632e439f11
MD5 177b6a2fb2700cbb71a87b9afb547ef2
BLAKE2b-256 ccefb03ac20444e44ef3d3cc21349d4d601f4a576ce85a3fcc757078a0e4929e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_language_pack-1.3.0-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.3.0-cp310-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_language_pack-1.3.0-cp310-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 735b7583fd23d9dcae549de647dd471b56e02fc983447fcde70d3287ae9260f8
MD5 c10220bc3ce704124f311946f108178c
BLAKE2b-256 4fdb4cde2ef7268fcb4e3dc55dcea5755eb96556e9bd0e35229d3e132bbd1fb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_language_pack-1.3.0-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.3.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_language_pack-1.3.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5bea10af088da1c2b9246b932907b19adf55465fb77b86dc2eb8d8c75d63bbc
MD5 6c6bd79e30733ffcccb7c231312ac783
BLAKE2b-256 99844f5edd6c6ec76a8770e6339c33658853d7d8f4d58d82873bb3d5b2ecc97e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_language_pack-1.3.0-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