fix: use correct Python interpreter for pipx installs

This commit is contained in:
Safi
2026-04-06 16:06:31 +01:00
parent c1bf6c90dc
commit 07de9d5c22
2 changed files with 45 additions and 34 deletions
+44 -33
View File
@@ -58,15 +58,26 @@ Follow these steps in order. Do not skip steps.
### Step 1 - Ensure graphify is installed
```bash
python3 -c "import graphify" 2>/dev/null || pip install graphifyy -q --break-system-packages 2>&1 | tail -3
# Detect the correct Python interpreter (handles pipx, venv, system installs)
GRAPHIFY_BIN=$(which graphify 2>/dev/null)
if [ -n "$GRAPHIFY_BIN" ]; then
PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!')
else
PYTHON="python3"
fi
$PYTHON -c "import graphify" 2>/dev/null || pip install graphifyy -q --break-system-packages 2>&1 | tail -3
# Write interpreter path for all subsequent steps
$PYTHON -c "import sys; open('.graphify_python', 'w').write(sys.executable)"
```
If the import succeeds, print nothing and move straight to Step 2.
**In every subsequent bash block, replace `python3` with `$(cat .graphify_python)` to use the correct interpreter.**
### Step 2 - Detect files
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from graphify.detect import detect
from pathlib import Path
@@ -106,7 +117,7 @@ Note: Parallelizing AST + semantic saves 5-15s on large corpora. AST is determin
For any code files detected, run AST extraction in parallel with Part B subagents:
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.extract import collect_files, extract
from pathlib import Path
@@ -144,7 +155,7 @@ Before dispatching subagents, print a timing estimate:
Before dispatching any subagents, check which files already have cached extraction results:
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from graphify.cache import check_semantic_cache
from pathlib import Path
@@ -244,7 +255,7 @@ If more than half the chunks failed, stop and tell the user.
Save new results to cache:
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from graphify.cache import save_semantic_cache
from pathlib import Path
@@ -257,7 +268,7 @@ print(f'Cached {saved} files')
Merge cached + new results into `.graphify_semantic.json`:
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from pathlib import Path
@@ -290,7 +301,7 @@ Clean up temp files: `rm -f .graphify_cached.json .graphify_uncached.txt .graphi
#### Part C - Merge AST + semantic into final extraction
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from pathlib import Path
@@ -325,7 +336,7 @@ print(f'Merged: {total} nodes, {edges} edges ({len(ast[\"nodes\"])} AST + {len(s
```bash
mkdir -p graphify-out
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.cluster import cluster, score_all
@@ -378,7 +389,7 @@ Read `.graphify_analysis.json`. For each community key, look at its node labels
Then regenerate the report and save the labels for the visualizer:
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.cluster import score_all
@@ -418,7 +429,7 @@ Replace INPUT_PATH with the actual path.
If `--obsidian` was given:
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.export import to_obsidian, to_canvas
@@ -449,7 +460,7 @@ print(' _COMMUNITY_* - overview notes with cohesion scores and dataview queries
Generate the HTML graph (always, unless `--no-viz`):
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.export import to_html
@@ -476,7 +487,7 @@ else:
**If `--neo4j`** - generate a Cypher file for manual import:
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.export import to_cypher
@@ -491,7 +502,7 @@ print('cypher.txt written - import with: cypher-shell < graphify-out/cypher.txt'
**If `--neo4j-push <uri>`** - push directly to a running Neo4j instance. Ask the user for credentials if not provided:
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.cluster import cluster
@@ -513,7 +524,7 @@ Replace `NEO4J_URI`, `NEO4J_USER`, `NEO4J_PASSWORD` with actual values. Default
### Step 7b - SVG export (only if --svg flag)
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.export import to_svg
@@ -535,7 +546,7 @@ print('graph.svg written - embeds in Obsidian, Notion, GitHub READMEs')
### Step 7c - GraphML export (only if --graphml flag)
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from graphify.build import build_from_json
from graphify.export import to_graphml
@@ -577,7 +588,7 @@ To configure in Claude Desktop, add to `claude_desktop_config.json`:
If `total_words` from `.graphify_detect.json` is greater than 5,000, run:
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from graphify.benchmark import run_benchmark, print_benchmark
from pathlib import Path
@@ -595,7 +606,7 @@ Print the output directly in chat. If `total_words <= 5000`, skip silently - the
### Step 9 - Save manifest, update cost tracker, clean up, and report
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from pathlib import Path
from datetime import datetime, timezone
@@ -629,7 +640,7 @@ cost_path.write_text(json.dumps(cost, indent=2))
print(f'This run: {input_tok:,} input tokens, {output_tok:,} output tokens')
print(f'All time: {cost[\"total_input_tokens\"]:,} input, {cost[\"total_output_tokens\"]:,} output ({len(cost[\"runs\"])} runs)')
"
rm -f .graphify_detect.json .graphify_extract.json .graphify_ast.json .graphify_semantic.json .graphify_analysis.json .graphify_labels.json
rm -f .graphify_detect.json .graphify_extract.json .graphify_ast.json .graphify_semantic.json .graphify_analysis.json .graphify_labels.json .graphify_python
rm -f graphify-out/.needs_update 2>/dev/null || true
```
@@ -667,7 +678,7 @@ The graph is the map. Your job after the pipeline is to be the guide.
Use when you've added or modified files since the last run. Only re-extracts changed files - saves tokens and time.
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.detect import detect_incremental, save_manifest
from pathlib import Path
@@ -686,7 +697,7 @@ print(f'{new_total} new/changed file(s) to re-extract.')
If new files exist, first check whether all changed files are code files:
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from pathlib import Path
@@ -706,7 +717,7 @@ If `code_only` is False (any changed file is a doc/paper/image): run the full St
Then:
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.export import to_json
@@ -733,7 +744,7 @@ Then run Steps 48 on the merged graph as normal.
After Step 4, show the graph diff:
```bash
python3 -c "
$(cat .graphify_python) -c "
import json
from graphify.analyze import graph_diff
from graphify.build import build_from_json
@@ -767,7 +778,7 @@ Clean up after: `rm -f .graphify_old.json`
Skip Steps 13. Load the existing graph from `graphify-out/graph.json` and re-run clustering:
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from graphify.cluster import cluster, score_all
from graphify.analyze import god_nodes, surprising_connections
@@ -820,7 +831,7 @@ Two traversal modes - choose based on the question:
First check the graph exists:
```bash
python3 -c "
$(cat .graphify_python) -c "
from pathlib import Path
if not Path('graphify-out/graph.json').exists():
print('ERROR: No graph found. Run /graphify <path> first to build the graph.')
@@ -838,7 +849,7 @@ Load `graphify-out/graph.json`, then:
5. If the graph lacks enough information, say so - do not hallucinate edges.
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys, json
from networkx.readwrite import json_graph
import networkx as nx
@@ -929,7 +940,7 @@ Replace `QUESTION` with the user's actual question, `MODE` with `bfs` or `dfs`,
After writing the answer, save it back into the graph so it improves future queries:
```bash
python3 -c "
$(cat .graphify_python) -c "
from graphify.ingest import save_query_result
from pathlib import Path
save_query_result(
@@ -953,7 +964,7 @@ Find the shortest path between two named concepts in the graph.
First check the graph exists:
```bash
python3 -c "
$(cat .graphify_python) -c "
from pathlib import Path
if not Path('graphify-out/graph.json').exists():
print('ERROR: No graph found. Run /graphify <path> first to build the graph.')
@@ -963,7 +974,7 @@ if not Path('graphify-out/graph.json').exists():
If it fails, stop and tell the user to run `/graphify <path>` first.
```bash
python3 -c "
$(cat .graphify_python) -c "
import json, sys
import networkx as nx
from networkx.readwrite import json_graph
@@ -1015,7 +1026,7 @@ Replace `NODE_A` and `NODE_B` with the actual concept names from the user. Then
After writing the explanation, save it back:
```bash
python3 -c "
$(cat .graphify_python) -c "
from graphify.ingest import save_query_result
from pathlib import Path
save_query_result(
@@ -1037,7 +1048,7 @@ Give a plain-language explanation of a single node - everything connected to it.
First check the graph exists:
```bash
python3 -c "
$(cat .graphify_python) -c "
from pathlib import Path
if not Path('graphify-out/graph.json').exists():
print('ERROR: No graph found. Run /graphify <path> first to build the graph.')
@@ -1047,7 +1058,7 @@ if not Path('graphify-out/graph.json').exists():
If it fails, stop and tell the user to run `/graphify <path>` first.
```bash
python3 -c "
$(cat .graphify_python) -c "
import json, sys
import networkx as nx
from networkx.readwrite import json_graph
@@ -1092,7 +1103,7 @@ Replace `NODE_NAME` with the concept the user asked about. Then write a 3-5 sent
After writing the explanation, save it back:
```bash
python3 -c "
$(cat .graphify_python) -c "
from graphify.ingest import save_query_result
from pathlib import Path
save_query_result(
@@ -1113,7 +1124,7 @@ print('Explanation saved to graphify-out/memory/')
Fetch a URL and add it to the corpus, then update the graph.
```bash
python3 -c "
$(cat .graphify_python) -c "
import sys
from graphify.ingest import ingest
from pathlib import Path
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "graphifyy"
version = "0.2.1"
version = "0.2.2"
description = "Claude Code skill - turn any folder of code, docs, papers, images, or tweets into a queryable knowledge graph"
readme = "README.md"
license = { text = "MIT" }