Skip to main content

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


Download files

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

Source Distribution

code2graph_rs-0.0.0b6.tar.gz (366.6 kB view details)

Uploaded Source

Built Distributions

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

code2graph_rs-0.0.0b6-cp39-abi3-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

code2graph_rs-0.0.0b6-cp39-abi3-musllinux_1_2_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

code2graph_rs-0.0.0b6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

code2graph_rs-0.0.0b6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

code2graph_rs-0.0.0b6-cp39-abi3-macosx_11_0_arm64.whl (5.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

code2graph_rs-0.0.0b6-cp39-abi3-macosx_10_12_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file code2graph_rs-0.0.0b6.tar.gz.

File metadata

  • Download URL: code2graph_rs-0.0.0b6.tar.gz
  • Upload date:
  • Size: 366.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for code2graph_rs-0.0.0b6.tar.gz
Algorithm Hash digest
SHA256 5ad0f86dbad8dec9ea40a852e229f031597ebdad08366987a541d51b8bcc37ea
MD5 c8e38ecd80ba6009beffd99541dd6663
BLAKE2b-256 38b38ce0dde443bc1d086042c32a36154681671f4ccce3958e3d79a1f0ae0923

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b6.tar.gz:

Publisher: release.yml on NodeDB-Lab/code2graph

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

File details

Details for the file code2graph_rs-0.0.0b6-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b6-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 14ef4dc474952bc450309d8330c54badb6c3ad415c3c637b4f2a2de63e848e71
MD5 157a41600fe22685c69aba66e5ad4110
BLAKE2b-256 107dcc179ee203784209ce7a97871a5ff8aa41f66c84a126139102be4bfc78ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b6-cp39-abi3-win_amd64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

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

File details

Details for the file code2graph_rs-0.0.0b6-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b6-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4e67a3db37e4b5b42b64cbd60d58ace9181b89a9d7d3370c6882fea19bbaa932
MD5 72da0f971d02e9fc8aca5ce144e31840
BLAKE2b-256 efda6ba9599a4dca39b280f3e2d83aee6df0a38c6001252ed469bd2d86347200

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b6-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

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

File details

Details for the file code2graph_rs-0.0.0b6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6ae48a123d11cfd8e8bf4f266c57c7f5c71a276b50fac80e1ff2e8395b9dd974
MD5 65a38ff0e8c39bd9ed005645110f0ec3
BLAKE2b-256 5b3143aacf6f7778a67cdd7fa195037dcd7aa748a95e7e73db2f3fa086d78f0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

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

File details

Details for the file code2graph_rs-0.0.0b6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3dcc16080d4e6b091e155fd895a51c9f13fdb487d32d794e06ad067fcbba8982
MD5 b83ed3a798f5ba36f21c703cbbbe59aa
BLAKE2b-256 1afcdb525ee0b7d4d6e5ec5e43a247bd0fd26a6a0c10db26be7923a8a96e1b3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

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

File details

Details for the file code2graph_rs-0.0.0b6-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b6-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80dc6872770f72f92dd653078b3f74987e71385b328ae7c5d3617147854bd87e
MD5 5f6a58aaa6dc2f8fbc3a015fb4a48b57
BLAKE2b-256 16ad6259386ddd2e4a02be075401bce0693a51516e0a68a5174d7c5dc2dd51fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b6-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

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

File details

Details for the file code2graph_rs-0.0.0b6-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b6-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4fb3fb2bd756cec8768f9e22fe42d943f8543077ad86fe2864ea417f8f7c4952
MD5 b798374ed7a55cf11625dfccf95c243c
BLAKE2b-256 91907a1a8f153b3e0068761c723421b3022cecfc569f93f9d521ff36d7b07819

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b6-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

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