mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-03 08:17:52 +00:00
refactor(env+install/spot): collapse python/venv resolution into shell SPOT
Pulls VENV/PYTHON/PIP/PYTHONPATH out of the dotenv handler pipeline
into scripts/meta/python/detect.sh. load.sh now sources detect.sh and
prepends ${VENV}/bin to PATH above the INFINITO_ENV_LOADED guard, so
every BASH_ENV re-entry re-resolves PYTHON the moment a venv
materialises mid-chain — the same fix as b79ed2869 but at the SPOT,
which retires the reload-trick from ansible.sh, python.sh and
pre-commit.sh.
Also renames INVENTORY_VARS_FILE → INFINITO_INVENTORY_VARS_FILE under
the new env-prefix lint, drops the 5 dead INFINITO_ENV_*_LOADED unsets
left over from the multi-loader era, and adds a lint guarding the
INFINITO_ prefix invariant on env/*.env keys.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
20b78fa778
commit
80c396b839
26 files changed
+172
-257
No files matched your search
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# SPOT for venv + Python interpreter resolution. Exports VENV, PYTHON,
|
||||
# PIP, PYTHONPATH. Sourced; re-entrant.
|
||||
|
||||
VENV_NAME=infinito
|
||||
|
||||
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
|
||||
VENV_BASE="$(dirname "${VIRTUAL_ENV}")"
|
||||
elif [[ -d /opt/venvs && -w /opt/venvs ]]; then
|
||||
VENV_BASE=/opt/venvs
|
||||
else
|
||||
VENV_BASE="${HOME}/.venvs"
|
||||
fi
|
||||
|
||||
VENV_FALLBACK="${VENV_BASE%/}/${VENV_NAME}"
|
||||
VENV="${VENV:-${VIRTUAL_ENV:-${VENV_FALLBACK}}}"
|
||||
|
||||
if [[ -x "${VENV}/bin/python" ]]; then
|
||||
PYTHON="${VENV}/bin/python"
|
||||
elif command -v python3 >/dev/null 2>&1; then
|
||||
PYTHON=python3
|
||||
else
|
||||
echo "detect.sh: no python3 on PATH and no venv at ${VENV}/bin/python" >&2
|
||||
# shellcheck disable=SC2317
|
||||
return 1 2>/dev/null || exit 1
|
||||
fi
|
||||
|
||||
PIP="${PYTHON} -m pip"
|
||||
PYTHONPATH="${PYTHONPATH:-.}"
|
||||
|
||||
export VENV PYTHON PIP PYTHONPATH
|
||||
Reference in new issue
Block a user