fix: bootstrap pip via ensurepip if missing from venv

On Arch Linux, venvs can be created without pip seeded in.
Detect the missing module before attempting pip install and
recover with `python -m ensurepip --upgrade`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-04-08 21:17:52 -04:00
parent 576f22216a
commit f668826f79

View File

@@ -117,6 +117,12 @@ def setup_venv(dry_run=False):
# Always (re-)install requirements so updates are picked up
if not dry_run:
# Bootstrap pip if the venv was created without it (common on Arch)
code, _, _ = run_quiet([str(VENV_PYTHON), "-m", "pip", "--version"])
if code != 0:
info("pip not found in venv — bootstrapping via ensurepip …")
run([str(VENV_PYTHON), "-m", "ensurepip", "--upgrade"])
info("Installing / updating requirements …")
run([str(VENV_PYTHON), "-m", "pip", "install", "--quiet", "--upgrade", "pip"])
run([str(VENV_PYTHON), "-m", "pip", "install", "--quiet", "-r", str(REQUIREMENTS)])