chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
```bash
|
||||
# Detect the correct Python interpreter (handles uv tool, pipx, venv, system installs)
|
||||
PYTHON=""
|
||||
GRAPHIFY_BIN=$(which graphify 2>/dev/null)
|
||||
# 1. uv tool installs — most reliable on modern Mac/Linux
|
||||
if [ -z "$PYTHON" ] && command -v uv >/dev/null 2>&1; then
|
||||
_UV_PY=$(uv tool run --from graphifyy python -c "import sys; print(sys.executable)" 2>/dev/null)
|
||||
if [ -n "$_UV_PY" ]; then PYTHON="$_UV_PY"; fi
|
||||
fi
|
||||
# 2. Read shebang from graphify binary (pipx and direct pip installs)
|
||||
if [ -z "$PYTHON" ] && [ -n "$GRAPHIFY_BIN" ]; then
|
||||
_SHEBANG=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!')
|
||||
case "$_SHEBANG" in
|
||||
*[!a-zA-Z0-9/_.@-]*) ;;
|
||||
*) "$_SHEBANG" -c "import graphify" 2>/dev/null && PYTHON="$_SHEBANG" ;;
|
||||
esac
|
||||
fi
|
||||
# 3. Fall back to python3
|
||||
if [ -z "$PYTHON" ]; then PYTHON="python3"; fi
|
||||
if ! "$PYTHON" -c "import graphify" 2>/dev/null; then
|
||||
if command -v uv >/dev/null 2>&1; then
|
||||
uv tool install --upgrade graphifyy -q 2>&1 | tail -3
|
||||
_UV_PY=$(uv tool run --from graphifyy python -c "import sys; print(sys.executable)" 2>/dev/null)
|
||||
if [ -n "$_UV_PY" ]; then PYTHON="$_UV_PY"; fi
|
||||
else
|
||||
"$PYTHON" -m pip install graphifyy -q 2>/dev/null \
|
||||
|| "$PYTHON" -m pip install graphifyy -q --break-system-packages 2>&1 | tail -3
|
||||
fi
|
||||
fi
|
||||
# Write interpreter path for all subsequent steps (persists across invocations)
|
||||
mkdir -p graphify-out
|
||||
"$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)"
|
||||
# Save scan root so `graphify update` (no args) knows where to look next time
|
||||
echo "$(cd INPUT_PATH && pwd)" > graphify-out/.graphify_root
|
||||
```
|
||||
|
||||
If the import succeeds, print nothing and move straight to Step 2.
|
||||
|
||||
**In every subsequent bash block, replace `python3` with `$(cat graphify-out/.graphify_python)` to use the correct interpreter.**
|
||||
@@ -0,0 +1,61 @@
|
||||
```powershell
|
||||
# Detect Python with graphify — uv/pipx-aware (fixes #831)
|
||||
New-Item -ItemType Directory -Force -Path graphify-out | Out-Null
|
||||
$GRAPHIFY_PYTHON = $null
|
||||
|
||||
function Find-GraphifyPython {
|
||||
# 1. uv tool install — 'uv tool dir' is authoritative, respects UV_TOOL_DIR automatically
|
||||
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
||||
$uvDir = (uv tool dir 2>$null).Trim()
|
||||
if ($uvDir) {
|
||||
$py = Join-Path $uvDir "graphifyy\Scripts\python.exe"
|
||||
if (Test-Path $py) {
|
||||
& $py -c "import graphify" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) { return $py }
|
||||
}
|
||||
}
|
||||
}
|
||||
# 2. pipx install — 'pipx environment' respects PIPX_HOME automatically
|
||||
if (Get-Command pipx -ErrorAction SilentlyContinue) {
|
||||
$venvs = (pipx environment --value PIPX_LOCAL_VENVS 2>$null).Trim()
|
||||
if ($venvs) {
|
||||
$py = Join-Path $venvs "graphifyy\Scripts\python.exe"
|
||||
if (Test-Path $py) {
|
||||
& $py -c "import graphify" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) { return $py }
|
||||
}
|
||||
}
|
||||
}
|
||||
# 3. Active venv / conda / pip-into-current-env
|
||||
$pyCmd = Get-Command python -ErrorAction SilentlyContinue
|
||||
if ($pyCmd) {
|
||||
& $pyCmd.Source -c "import graphify" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
return (& $pyCmd.Source -c "import sys; print(sys.executable)").Trim()
|
||||
}
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
# Try to find the right Python (uv → pipx → active env)
|
||||
$GRAPHIFY_PYTHON = Find-GraphifyPython
|
||||
|
||||
# Not found — install then re-detect
|
||||
if (-not $GRAPHIFY_PYTHON) {
|
||||
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
||||
uv tool install --upgrade graphifyy -q 2>&1 | Select-Object -Last 3
|
||||
} else {
|
||||
pip install graphifyy -q 2>&1 | Select-Object -Last 3
|
||||
}
|
||||
$GRAPHIFY_PYTHON = Find-GraphifyPython
|
||||
}
|
||||
|
||||
# Save interpreter path — all subsequent steps read this
|
||||
$GRAPHIFY_PYTHON | Out-File -FilePath graphify-out\.graphify_python -Encoding utf8 -NoNewline
|
||||
# Save scan root so `graphify update` (no args) knows where to look next time
|
||||
(Resolve-Path INPUT_PATH).Path | Out-File -FilePath graphify-out\.graphify_root -Encoding utf8 -NoNewline
|
||||
```
|
||||
|
||||
If the import succeeds, print nothing and move straight to Step 2.
|
||||
|
||||
**In every subsequent block, run Python through the saved interpreter — `& (Get-Content graphify-out\.graphify_python)` in place of a bare `python3` — so every step uses the interpreter that actually has graphify.**
|
||||
Reference in New Issue
Block a user