refactor: install Python CLI into isolated venv instead of uv tool#1909
refactor: install Python CLI into isolated venv instead of uv tool#1909
Conversation
Replace `uv tool install` (which installs globally into ~/.local/bin) with a dedicated venv at an OS-specific cache directory (~/.cache/codeflash/venv on Linux, ~/Library/Caches/codeflash/venv on macOS, %LOCALAPPDATA%\codeflash\venv on Windows). The CLI entry point now invokes the binary directly from the venv instead of via `uv tool run`. Also strips VIRTUAL_ENV/CONDA env vars from child processes to avoid interference from activated environments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @mohammedahmed18's task in 2m 58s —— View job PR Review Summary
Prek ChecksNo Python files changed; prek reported no files to check. ✓ Code ReviewBug — silent failure if verification fails
// Current — return value ignored
verifyInstallation();
// Should be:
if (!verifyInstallation()) {
logWarning('Could not verify installation — run `npx codeflash --version` to test');
}Issue —
execSync(`"${uvBin}" venv --python python3.12 --clear "${venvDir}"`, ...);
const codeflashBin = getCodeflashBin();
if (!fs.existsSync(codeflashBin)) {
// only create venv if binary is missing
execSync(`"${uvBin}" venv --python python3.12 "${venvDir}"`, ...);
}Or at minimum drop Issue —
execSync(`"${uvBin}" pip install --python "${venvDir}" "${GITHUB_REPO}"`, ...);Passing the venv directory to const pythonBin = os.platform() === 'win32'
? path.join(venvDir, 'Scripts', 'python.exe')
: path.join(venvDir, 'bin', 'python3');
execSync(`"${uvBin}" pip install --python "${pythonBin}" "${GITHUB_REPO}"`, ...);This avoids relying on uv's directory detection heuristic and makes it clear which Python is targeted. Minor — step numbering is slightly off
Duplicate Detection
Test CoverageJavaScript files only — Python coverage tooling does not apply. The PR test plan (manual) is clear and comprehensive. Last updated: 2026-03-26 |
aseembits93
left a comment
There was a problem hiding this comment.
lgtm, windows could possibly an issue, let's see
Follow-up to #1909 — the npm package now installs into a dedicated venv instead of using uv tool, but these references were missed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
uv tool install(global install to~/.local/bin) with a dedicated venv in an OS-specific cache directory (~/.cache/codeflash/venvon Linux,~/Library/Caches/codeflash/venvon macOS,%LOCALAPPDATA%\codeflash\venvon Windows)uv tool runVIRTUAL_ENV/CONDA_PREFIXenv vars from child processes to avoid interference from activated environmentsscripts/paths.jsmodule for OS-specific path resolutionTest plan
npm installinpackages/codeflash— verify postinstall creates venv at the expected cache pathnpx codeflash --version— verify it invokes the binary from the cache venv🤖 Generated with Claude Code