Skip to content

ga script should prefer project's .venv over system python #433

@HamsteRider-m

Description

@HamsteRider-m

Issue: ga script should prefer project's .venv over system python

Problem

The ga launcher script currently uses python from PATH, which may point to system python. This causes issues on systems with Homebrew Python (macOS) due to PEP 668 protection:

  1. When running ga update, it executes pip install -e . using system python
  2. Homebrew Python blocks this with: error: externally-managed-environment
  3. Users must use --break-system-packages, which pollutes system python

Current Behavior

File: ga

#!/usr/bin/env bash
cd "$(dirname "$0")"
exec python -m ga_cli "$@"
  • Uses python from PATH (often system python)
  • Project dependencies are in .venv but not accessible
  • ga update fails with PEP 668 error

Expected Behavior

The ga script should:

  1. Prefer .venv/bin/python if it exists
  2. Fall back to python from PATH if no venv

Proposed Solution

Modify ga script:

#!/usr/bin/env bash
cd "$(dirname "$0")"
if [ -x .venv/bin/python ]; then
  exec .venv/bin/python -m ga_cli "$@"
else
  exec python -m ga_cli "$@"
fi

Benefits

  • ✅ Respects project's virtual environment
  • ✅ Avoids polluting system python
  • ga update works without --break-system-packages
  • ✅ Follows Python best practices
  • ✅ Compatible with PEP 668 (Homebrew Python)

Environment

  • OS: macOS (Homebrew Python 3.14)
  • Python: System python 3.14, project .venv python 3.12
  • Error: externally-managed-environment when running ga update

Workaround (Current)

Manually update in venv:

cd /path/to/GenericAgent
git pull
.venv/bin/pip install -e .

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions