No project description provided
Project description
Stack-Graphs Python bindings
Opinionated Python bindings for the tree-sitter-stack-graphs rust library.
It exposes very few, easy to use functions to index files and query references.
This is a proof of concept draft, to test scripting utilities using stack-graphs easily.
It uses pyo3 and maturin to generate the bindings.
Installation & Usage
pip install stack-graphs-python-bindings # or poetry, ...
import os
from stack_graphs_python import index, Querier, Position, Language
db_path = os.path.abspath("./db.sqlite")
dir = os.path.abspath("./tests/js_sample")
# Index the directory (creates stack-graphs database)
index([dir], db_path, language=Language.JavaScript)
# Instantiate a querier
querier = Querier(db_path)
# Query a reference at a given position (0-indexed line and column):
# foo in: const baz = foo
source_reference = Position(path=dir + "/index.js", line=2, column=12)
results = querier.definitions(source_reference)
for r in results:
print(f"{r.path}, l:{r.line}, c: {r.column}")
Will result in:
[...]/stack-graphs-python-bindings/tests/js_sample/index.js, l:0, c: 9
[...]/stack-graphs-python-bindings/tests/js_sample/module.js, l:0, c: 13
That translates to:
// index.js
import { foo } from "./module"
// module.js
export const foo = "bar"
Development
Ressources
https://pyo3.rs/v0.21.2/getting-started
Requirements
- Rust
- Python 3.11+
Setup
# Setup venv and install maturin through pip
make setup
Testing
make test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Close
Hashes for stack_graphs_python_bindings-0.0.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a51a5cac7dfff607edbcf87e7d296c97917f77dd6437293d29c933387b3ff9d8 |
|
MD5 | 2e97116c18506de768860e13e85961ae |
|
BLAKE2b-256 | d98d87ff4505177b44a4c8f1aac75b05fe9e1d5b46c4715ab3ac99780ccd9d30 |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ba636197aedce1fa16ab89ee13562f7cbf91473e2c18c7ed3a39d3459fa91ff |
|
MD5 | 030112cc398d19ec766f2a89da2176a7 |
|
BLAKE2b-256 | 07ae3d10203cae9315631e73bebb21f87e26ed51c0afb608b4a4e1dc0a43cfd0 |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e724e528e0ec7e54715434587bc23732fd17854c3be145b94b4a10f232f4d042 |
|
MD5 | 3338433bcff5405cb598432671283282 |
|
BLAKE2b-256 | c089b283abdf9215c6a394ec21b60df25c6020e6f370aca13e077df501ccd677 |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d35c4d325b0e69f4a357ff5f887cfdd119ebd2e417b2a5b0fd364874d403a0cc |
|
MD5 | c7643353884c4bf4661ed4991ff66621 |
|
BLAKE2b-256 | 72ff1352a3a152ccce59484d18c940c94506c1cdf7bafb39259272f72129991e |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f252550eadb17bc7e72f3eb6c357e3505ae9d366dd0c41ac21d321c542d3be |
|
MD5 | 1a91b59af0e52c4aa6fe45c9fa83a74f |
|
BLAKE2b-256 | e9a97351fdefecefabd638fe0b211bfd3ee7cb438d5d9fdf16434e1cef01d08c |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c383994c0d36483918799ce2edd786e2da7e05a1dafe0655bdbbfc3c7c6aabac |
|
MD5 | 8fa345c18db3418c550583f153729318 |
|
BLAKE2b-256 | 50733ee3e6cb263b16e2676c43f20aaf8fa887a012abd9a9c8cc8fe52562bc13 |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54289d054cbfd0d6fcdee441cee8bba2ef0920d737a4e3a5714b1b9e979ab588 |
|
MD5 | 1fdf8895da0e69764b3e363f443777cc |
|
BLAKE2b-256 | 5a78e897ee3b3fb34bf568ab99b70b3a95ce29cb25e80157f070a93fba82ac66 |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4fc0e2e43bd80d55a9a39234d9b31e6ff643284244d1797012635acd55e4026 |
|
MD5 | 734b7a86f39e4d87cccf06789a7e5ddf |
|
BLAKE2b-256 | 0e8c16107be206fd49b979f62c7837112380d6d9aaf1308287ecbee2170af3fe |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84fdd9ec8774a48e841e4bbf0465f83753923b8a388e363eb5bcfe455b619793 |
|
MD5 | 7fa3ed882b548e84f47f3a6556babc6e |
|
BLAKE2b-256 | 305a102a299e59950ccb1f5366a1f912013d20b3b45febfa07ce816802cab908 |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | effd065719d61fb3a28b91eeeb93fbbe985fbb0f12d9c7a1952b890d430e1b32 |
|
MD5 | 1568fa199e9b2588c207d0b8f7e24d70 |
|
BLAKE2b-256 | 4187006241b0bc4d5245e5e4a2a4eae77df73bdeeb6af0798270f6c20fac5394 |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bae58be7209c23f80bdb293adae28431cff9a05fb724f018c5e73037e36e59b |
|
MD5 | 10bf57ca12c5ae716499552a12c40396 |
|
BLAKE2b-256 | e0b0b319eac67c7ef26e506a53ac4a612ec48ea00dc17f533f06ad7d01635486 |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86d7a0bc3bfc3a8e729559f07ecfb26628d97565258ef09fa89d28fdc8b8ba8a |
|
MD5 | ca4c9a284968d54d685bbd61b4de3744 |
|
BLAKE2b-256 | b8bce7f1b8a7e6cdb27973a82c6f4ce6c55663e310538ca276013044cd9619fa |
Close
Hashes for stack_graphs_python_bindings-0.0.9-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e36c6eb0697d9b928a8279c76b4e54144313aa0c152c36418e7d879e43fbb3da |
|
MD5 | f7bce35e265e9ff05d1fffb57ca8dc47 |
|
BLAKE2b-256 | 0f895a0863254625d37d536a4fe81d4c084995421e2b459e38a9f341138cbd1c |