Source code to structural graph facts — Python bindings
Project description
code2graph — Python bindings
Python bindings to the code2graph Rust library, which turns source files into structural facts: symbols (definitions), references (use sites), and cross-file edges.
Build
Inside a virtualenv, from the bindings/python directory:
pip install maturin
maturin develop
This compiles the Rust extension and installs it into the active virtualenv. The published distribution is named code2graph-rs (pip install code2graph-rs); the import name is code2graph.
Usage
import code2graph
facts = code2graph.extract("src/lib.rs", "pub fn hello() {}")
print(facts["symbols"])
extract(file, source) returns a dict mirroring the FileFacts schema (keys: symbols, references,
scopes, bindings, ffi_exports). SymbolId values appear as their stable SCIP strings.
Resolve facts from multiple files into a cross-file graph with build_graph:
import code2graph
a = code2graph.extract("src/util.rs", "pub fn helper() {}")
b = code2graph.extract("src/main.rs", "pub fn run() { helper() }")
graph = code2graph.build_graph([a, b], tier="name")
print(graph["edges"]) # each edge: from, to, role, confidence, provenance, occ
build_graph(files, tier="name") returns a dict mirroring CodeGraph (symbols + edges). The tier
argument selects the resolver: "name" (default, Tier A — fast, recall-first, NameOnly confidence) or
"scope" (Tier B — scope-graph path resolution, Scoped/Exact confidence). The helper
language_of(path) returns the canonical language tag for a path (e.g. "rust"), or None if the
extension is unrecognized.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code2graph_rs-0.0.0b3.tar.gz.
File metadata
- Download URL: code2graph_rs-0.0.0b3.tar.gz
- Upload date:
- Size: 366.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89cd67a11d0f14e90eda319c62c3ea22e51fa6302fbfcc0243559ffcac66aeae
|
|
| MD5 |
97c2d26674bf605c06d4dd5f49da5f4c
|
|
| BLAKE2b-256 |
ab1973e4cc7492d5db8d8eb427c10fd46970bd7b895f8dd6d9bf02f3e4d99151
|
Provenance
The following attestation bundles were made for code2graph_rs-0.0.0b3.tar.gz:
Publisher:
release.yml on NodeDB-Lab/code2graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code2graph_rs-0.0.0b3.tar.gz -
Subject digest:
89cd67a11d0f14e90eda319c62c3ea22e51fa6302fbfcc0243559ffcac66aeae - Sigstore transparency entry: 1843464259
- Sigstore integration time:
-
Permalink:
NodeDB-Lab/code2graph@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Branch / Tag:
refs/tags/v0.0.0-beta.3 - Owner: https://github.com/NodeDB-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file code2graph_rs-0.0.0b3-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: code2graph_rs-0.0.0b3-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 4.9 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f27afa24f26b25234904a245fd41253373a27dec95fee2d39bb716168e1bbbef
|
|
| MD5 |
e9f95fc356289a54c54e89378857377d
|
|
| BLAKE2b-256 |
c37d4f68a5418c2d13c5c8669af29b58ab10af0e82626a938eeeef8ecdd76b66
|
Provenance
The following attestation bundles were made for code2graph_rs-0.0.0b3-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on NodeDB-Lab/code2graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code2graph_rs-0.0.0b3-cp39-abi3-win_amd64.whl -
Subject digest:
f27afa24f26b25234904a245fd41253373a27dec95fee2d39bb716168e1bbbef - Sigstore transparency entry: 1843464878
- Sigstore integration time:
-
Permalink:
NodeDB-Lab/code2graph@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Branch / Tag:
refs/tags/v0.0.0-beta.3 - Owner: https://github.com/NodeDB-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file code2graph_rs-0.0.0b3-cp39-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: code2graph_rs-0.0.0b3-cp39-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c7f6752549ce9b49df654b7307968f783b55dba8efde68e99b194f7f6c57df3
|
|
| MD5 |
df5f607f261fa0c1aea998b511c09dec
|
|
| BLAKE2b-256 |
8c205d171d83ddc62699958b75496d7681c8021cb20b312c33938585f2f3e936
|
Provenance
The following attestation bundles were made for code2graph_rs-0.0.0b3-cp39-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on NodeDB-Lab/code2graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code2graph_rs-0.0.0b3-cp39-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
1c7f6752549ce9b49df654b7307968f783b55dba8efde68e99b194f7f6c57df3 - Sigstore transparency entry: 1843465010
- Sigstore integration time:
-
Permalink:
NodeDB-Lab/code2graph@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Branch / Tag:
refs/tags/v0.0.0-beta.3 - Owner: https://github.com/NodeDB-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file code2graph_rs-0.0.0b3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: code2graph_rs-0.0.0b3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74f799786242c230482e936980e59fcad879da026e8650863af0dc49ab87c375
|
|
| MD5 |
34a0b9bc10e68a18b8d48ed5982d3341
|
|
| BLAKE2b-256 |
6a50b6233b726030dca4644793c6f808542025a99c3425c41f148f9c354cbdfd
|
Provenance
The following attestation bundles were made for code2graph_rs-0.0.0b3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on NodeDB-Lab/code2graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code2graph_rs-0.0.0b3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
74f799786242c230482e936980e59fcad879da026e8650863af0dc49ab87c375 - Sigstore transparency entry: 1843464956
- Sigstore integration time:
-
Permalink:
NodeDB-Lab/code2graph@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Branch / Tag:
refs/tags/v0.0.0-beta.3 - Owner: https://github.com/NodeDB-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file code2graph_rs-0.0.0b3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: code2graph_rs-0.0.0b3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b26c520864cb3554d82745345673f86731b97a68e6023320f7e01f95a2380fb7
|
|
| MD5 |
1aac3b07976535b7f6e0a148b597e431
|
|
| BLAKE2b-256 |
c829989b5ccb2ecb6f7596da709b9a0c5fcea0589b2045e054039170c5ca5ffd
|
Provenance
The following attestation bundles were made for code2graph_rs-0.0.0b3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on NodeDB-Lab/code2graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code2graph_rs-0.0.0b3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
b26c520864cb3554d82745345673f86731b97a68e6023320f7e01f95a2380fb7 - Sigstore transparency entry: 1843464391
- Sigstore integration time:
-
Permalink:
NodeDB-Lab/code2graph@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Branch / Tag:
refs/tags/v0.0.0-beta.3 - Owner: https://github.com/NodeDB-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file code2graph_rs-0.0.0b3-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: code2graph_rs-0.0.0b3-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34e4b7e787646d3e81673994fe3c7087aa666d7bf156b779a38c67777c32392c
|
|
| MD5 |
af452b6b61f64be07379e0167c7bce0a
|
|
| BLAKE2b-256 |
90369c522bbcedffcd539dbe1a61cb34eefb5a1d95aef3689c63fe019b82b454
|
Provenance
The following attestation bundles were made for code2graph_rs-0.0.0b3-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on NodeDB-Lab/code2graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code2graph_rs-0.0.0b3-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
34e4b7e787646d3e81673994fe3c7087aa666d7bf156b779a38c67777c32392c - Sigstore transparency entry: 1843464504
- Sigstore integration time:
-
Permalink:
NodeDB-Lab/code2graph@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Branch / Tag:
refs/tags/v0.0.0-beta.3 - Owner: https://github.com/NodeDB-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file code2graph_rs-0.0.0b3-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: code2graph_rs-0.0.0b3-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
360823071e86048b72aa6e242e8d7de0342f796c72556d748a951c08e9dbfd26
|
|
| MD5 |
325ecdb955d2874594fb13bd032c8fab
|
|
| BLAKE2b-256 |
9454a0a3001ba2b5cc30e03e1bc0df8f94fa9078abb217ef944950450081e62f
|
Provenance
The following attestation bundles were made for code2graph_rs-0.0.0b3-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on NodeDB-Lab/code2graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code2graph_rs-0.0.0b3-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
360823071e86048b72aa6e242e8d7de0342f796c72556d748a951c08e9dbfd26 - Sigstore transparency entry: 1843464691
- Sigstore integration time:
-
Permalink:
NodeDB-Lab/code2graph@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Branch / Tag:
refs/tags/v0.0.0-beta.3 - Owner: https://github.com/NodeDB-Lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea38c04cec63085d82e7201de83f42cbe6b381f2 -
Trigger Event:
push
-
Statement type: