cartograph-python 0.2.0__cp38-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cartograph/__init__.py +69 -0
- cartograph/__init__.pyi +483 -0
- cartograph/_cartograph.pyd +0 -0
- cartograph/aio.py +238 -0
- cartograph/codegraph.py +247 -0
- cartograph/dataframes.py +42 -0
- cartograph/igraph_adapter.py +51 -0
- cartograph/jupyter.py +38 -0
- cartograph/models.py +64 -0
- cartograph/networkx_adapter.py +35 -0
- cartograph/py.typed +1 -0
- cartograph_python-0.2.0.dist-info/METADATA +96 -0
- cartograph_python-0.2.0.dist-info/RECORD +15 -0
- cartograph_python-0.2.0.dist-info/WHEEL +4 -0
- cartograph_python-0.2.0.dist-info/sboms/cartograph-python.cyclonedx.json +9324 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""NetworkX graph conversion adapter for cartograph."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from typing import TYPE_CHECKING, Any
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
import networkx as nx
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def stream_to_networkx(streamer: Any) -> nx.DiGraph:
|
|
11
|
+
"""Stream graph nodes and edges directly into a NetworkX DiGraph."""
|
|
12
|
+
try:
|
|
13
|
+
import networkx as nx
|
|
14
|
+
except ImportError as e:
|
|
15
|
+
raise ImportError(
|
|
16
|
+
"networkx is not installed. Install it with: pip install 'cartograph[networkx]'"
|
|
17
|
+
) from e
|
|
18
|
+
|
|
19
|
+
g = nx.DiGraph()
|
|
20
|
+
|
|
21
|
+
for node_id, name, kind, filepath, start_line, end_line, complexity in streamer.get_nodes():
|
|
22
|
+
g.add_node(
|
|
23
|
+
node_id,
|
|
24
|
+
name=name,
|
|
25
|
+
kind=kind,
|
|
26
|
+
filepath=filepath,
|
|
27
|
+
start_line=start_line if start_line > 0 else None,
|
|
28
|
+
end_line=end_line if end_line > 0 else None,
|
|
29
|
+
complexity=complexity,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
for src, tgt, kind, weight in streamer.get_edges():
|
|
33
|
+
g.add_edge(src, tgt, kind=kind, weight=weight)
|
|
34
|
+
|
|
35
|
+
return g
|
cartograph/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Marker file for PEP 561
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cartograph-python
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: Intended Audience :: Science/Research
|
|
7
|
+
Classifier: Programming Language :: Rust
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
17
|
+
Requires-Dist: networkx>=3.0 ; extra == 'all'
|
|
18
|
+
Requires-Dist: python-igraph>=0.10 ; extra == 'all'
|
|
19
|
+
Requires-Dist: polars>=0.20 ; extra == 'all'
|
|
20
|
+
Requires-Dist: pandas>=2.0 ; extra == 'all'
|
|
21
|
+
Requires-Dist: pyarrow>=14.0 ; extra == 'all'
|
|
22
|
+
Requires-Dist: pytest>=8.0 ; extra == 'dev'
|
|
23
|
+
Requires-Dist: mypy>=1.9 ; extra == 'dev'
|
|
24
|
+
Requires-Dist: pyright>=1.1 ; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.4 ; extra == 'dev'
|
|
26
|
+
Requires-Dist: python-igraph>=0.10 ; extra == 'igraph'
|
|
27
|
+
Requires-Dist: networkx>=3.0 ; extra == 'networkx'
|
|
28
|
+
Requires-Dist: pandas>=2.0 ; extra == 'pandas'
|
|
29
|
+
Requires-Dist: pyarrow>=14.0 ; extra == 'pandas'
|
|
30
|
+
Requires-Dist: polars>=0.20 ; extra == 'polars'
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Provides-Extra: igraph
|
|
34
|
+
Provides-Extra: networkx
|
|
35
|
+
Provides-Extra: pandas
|
|
36
|
+
Provides-Extra: polars
|
|
37
|
+
Summary: Ultra-Fast Native AST Code Graph & Graph Data Science SDK
|
|
38
|
+
Keywords: code-graph,ast,pyo3,networkx,polars,ai-agents,static-analysis
|
|
39
|
+
Author: Pankaj Redekar
|
|
40
|
+
License: MIT OR Apache-2.0
|
|
41
|
+
Requires-Python: >=3.8
|
|
42
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
43
|
+
Project-URL: Bug Tracker, https://github.com/PankajRedekar/cartograph/issues
|
|
44
|
+
Project-URL: Documentation, https://github.com/PankajRedekar/cartograph#readme
|
|
45
|
+
Project-URL: Homepage, https://github.com/PankajRedekar/cartograph
|
|
46
|
+
Project-URL: Repository, https://github.com/PankajRedekar/cartograph
|
|
47
|
+
|
|
48
|
+
# cartograph-python
|
|
49
|
+
|
|
50
|
+
> **Ultra-Fast Native AST Code Graph & Graph Data Science SDK**
|
|
51
|
+
|
|
52
|
+
`cartograph-python` is the official Python SDK and high-performance PyO3 native extension for Cartograph. It provides sub-millisecond AST code graph queries, blast-radius impact analysis, zero-copy Apache Arrow exports to Polars & Pandas, and seamless conversion to NetworkX & igraph.
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Core SDK
|
|
58
|
+
pip install cartograph-python
|
|
59
|
+
|
|
60
|
+
# With all data science dependencies
|
|
61
|
+
pip install "cartograph-python[all]"
|
|
62
|
+
|
|
63
|
+
# Or specific extras:
|
|
64
|
+
pip install "cartograph-python[polars]"
|
|
65
|
+
pip install "cartograph-python[networkx]"
|
|
66
|
+
pip install "cartograph-python[igraph]"
|
|
67
|
+
pip install "cartograph-python[pandas]"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Quickstart
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import cartograph
|
|
74
|
+
|
|
75
|
+
# Open indexed repository code graph
|
|
76
|
+
with cartograph.open() as cg:
|
|
77
|
+
# 1. Locate symbol definition & callers
|
|
78
|
+
res = cg.locate("OrderService")
|
|
79
|
+
print(res)
|
|
80
|
+
|
|
81
|
+
# 2. Blast-radius impact analysis
|
|
82
|
+
impact = cg.impact("OrderService")
|
|
83
|
+
print(f"Risk score: {impact.risk_score}, dependents: {len(impact.affected_dependents)}")
|
|
84
|
+
|
|
85
|
+
# 3. Export to NetworkX DiGraph
|
|
86
|
+
G = cg.to_networkx()
|
|
87
|
+
|
|
88
|
+
# 4. Zero-copy export to Polars DataFrame
|
|
89
|
+
df = cg.nodes_dataframe(engine="polars")
|
|
90
|
+
print(df.head())
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT OR Apache-2.0
|
|
96
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
cartograph/__init__.py,sha256=h9q8pPrEvHIwhqOPOP2nWE67Zr_cAAabJWA6Wde_70I,1471
|
|
2
|
+
cartograph/__init__.pyi,sha256=C3n74o4IsEk_PmYrWECBz4sE19q0kOGsKKJe0vTNyTI,13504
|
|
3
|
+
cartograph/_cartograph.pyd,sha256=FyT3AAI0EvoF6puEECzBoIJpOZ52lOdRlpvAlAizlIA,20868608
|
|
4
|
+
cartograph/aio.py,sha256=TzOirXugb11A3eWd_Ib4sTVd0qM0tGkeENZjn24hmXQ,8463
|
|
5
|
+
cartograph/codegraph.py,sha256=HdMdW23Sx0UycwqZF-j7hb5H5MpBvXZtgW6kcK3-MBg,8537
|
|
6
|
+
cartograph/dataframes.py,sha256=So5eSDANKadWz4mT3hKvh1rspvsrkqphui2nlZeMBIQ,1383
|
|
7
|
+
cartograph/igraph_adapter.py,sha256=AU230-18YlmdrBc0K-FY4hJG-bI1RRHeSx8i7t0rtdo,1542
|
|
8
|
+
cartograph/jupyter.py,sha256=vNy1Zfsiqg71_dZDo09QcIbmENaUBhRPthOnP6yPYHw,1197
|
|
9
|
+
cartograph/models.py,sha256=27NiC1-yNhTi8K7NRZ48QHg3qYyNBTwulZckHUhi3e4,1319
|
|
10
|
+
cartograph/networkx_adapter.py,sha256=gMVEOyfCjUkhXQiUp-wuh1F3M7LLAoXyyxQ9jR6ZEGo,1072
|
|
11
|
+
cartograph/py.typed,sha256=TBDV9m9vjfnp9vsgTeJmpoNseoJEfHwvZaBLvLMfzz8,27
|
|
12
|
+
cartograph_python-0.2.0.dist-info/METADATA,sha256=6KtL1U7R_QDSJs23jL5lQ_FR9JjKADZUSX9SRxMJGeU,3434
|
|
13
|
+
cartograph_python-0.2.0.dist-info/WHEEL,sha256=mHg63_IuwLSNkYG18nNOcA-LX3sex5fkDDLT827pcck,95
|
|
14
|
+
cartograph_python-0.2.0.dist-info/sboms/cartograph-python.cyclonedx.json,sha256=U8wuQt7LymCTANt8hGIKsa6H-eDbsv0x9WHIsvPpXIc,301875
|
|
15
|
+
cartograph_python-0.2.0.dist-info/RECORD,,
|