Pick best available installer for generic Python project setup#591
Conversation
Generic pyproject.toml and requirements.txt projects hardcoded pip,
which fails on systems without a bare pip on PATH (e.g. macOS with
Homebrew Python only ships pip3) with:
Warning: Setup failed: /bin/sh: pip: command not found
Choose the installer at detection time instead, preferring uv
(uv venv + uv pip install, which targets the freshly created ./.venv
since run_setup clears VIRTUAL_ENV), then pip, then pip3. When no
installer is available, detection skips setup instead of failing.
As a bonus, the uv-created .venv means the direnv step now generates
a 'source .venv/bin/activate' .envrc for generic Python projects.
Greptile SummaryReplaces the hardcoded
Confidence Score: 5/5Safe to merge — the change is a targeted, well-tested fix with no regressions on existing project-type detection paths. The new helper follows an already-established pattern ( No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[detect_project_type] --> B{uv.lock or uv in pyproject.toml?}
B -- Yes --> C[python-uv: uv sync]
B -- No --> D{pixi.toml / pixi.lock?}
D -- Yes --> E[pixi: pixi install]
D -- No --> F{unidep project?}
F -- Yes --> G[python-unidep / monorepo]
F -- No --> H{poetry.lock?}
H -- Yes --> I[python-poetry: poetry install]
H -- No --> J[_detect_pip_install_project]
J --> K{requirements.txt exists?}
K -- Yes --> L[_python_install_commands]
K -- No --> M{pyproject.toml exists?}
L --> N{uv on PATH?}
N -- Yes --> O[python-pip: uv venv + uv pip install]
N -- No --> P{pip on PATH?}
P -- Yes --> Q[python-pip: pip install]
P -- No --> R{pip3 on PATH?}
R -- Yes --> S[python-pip: pip3 install]
R -- No --> M
M -- Yes --> T[_python_install_commands]
M -- No --> U[None — skip setup]
T --> V{uv on PATH?}
V -- Yes --> W[python: uv venv + uv pip install -e .]
V -- No --> X{pip on PATH?}
X -- Yes --> Y[python: pip install -e .]
X -- No --> Z{pip3 on PATH?}
Z -- Yes --> AA[python: pip3 install -e .]
Z -- No --> U
Reviews (2): Last reviewed commit: "Mock shutil.which in environment-sensiti..." | Re-trigger Greptile |
Generic Python detection now requires an installer on PATH, so tests asserting it must not depend on the host having uv/pip/pip3 installed. Addresses review feedback on #591.
Problem
ag dev newon a generic Python project (barepyproject.tomlorrequirements.txt) hardcodespip:macOS commonly has no bare
pipon PATH (Homebrew/Xcode Python only shippip3), so worktree setup always failed on these projects.Fix
Choose the installer at detection time, following the existing
_unidep_cmdavailability-check pattern:uv venv && uv pip install ...—uv venvcreates./.venvanduv pip installtargets it from the working directory (docs).run_setup()already clearsVIRTUAL_ENVfrom the subprocess env, so the caller's activated environment doesn't hijack the install (verified live).Bonus: since uv creates
./.venvduring setup, the subsequent direnv step now generates asource .venv/bin/activate.envrcfor generic Python projects (it previously found no venv).Tests
shutil.which, with evidence docstrings per repo convention (uv docs + live verification with uv 0.9).detect_project_type+run_setupon a temp pyproject project creates.venvand installs editable.