-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Bug Description
When running xaibo init in an existing uv workspace, the command:
- Removes the existing
.venvat the workspace root - Forces Python 3.10 even when Python 3.12 is available and preferred
This happens because the init command runs uv init --bare followed by uv add, which triggers uv to recreate the workspace virtual environment, and the generated requires-python = ">=3.10" causes uv to select the lowest compatible Python version.
The current behavior is particularly disruptive because:
- It destroys the existing venv without warning
- It silently downgrades Python versions, which can break other tools expecting a newer Python
- There's no way for the user to control this behavior via CLI arguments
Steps to Reproduce
- Have an existing uv workspace with a virtual environment
- Ensure Python 3.12 is available on your system
- Run:
uvx xaibo init my_first_agent
- Select any dependencies (e.g., webserver, openai, livekit)
- Observe the output:
Removed virtual environment at: /home/fahreza/Github/xaibo-test-2/.venv Creating virtual environment at: /home/fahreza/Github/xaibo-test-2/.venv Using CPython 3.10.15 interpreter at: /usr/bin/python3.10
Expected Behavior
- The existing venv should be preserved or at least recreated with the same Python version
- OR the user should be able to specify which Python version to use
Actual Behavior
- The venv is removed and recreated
- Python 3.10 is forced even when 3.12 is available
Root Cause Analysis
def init(args, extra_args=[]):
# ...
universal_run(f"uv init --bare {project_name}", cwd=curdir)
universal_run(f"uv add xaibo xaibo[{','.join(modules)}] pytest", cwd=project_dir)The uv add command in a workspace context triggers uv to sync the workspace environment, which recreates .venv. The generated pyproject.toml has requires-python = ">=3.10", so uv selects Python 3.10 (the lowest compatible version).
Proposed Solutions
Option 1: Add --python argument to init command (Recommended)
Allow users to specify their preferred Python version:
xaibo init my_agent --python 3.12Implementation:
init_parser.add_argument('--python', type=str, default='3.10',
help='Python version to use for the project (default: 3.10)')
# ...
universal_run(f"uv init --bare --python {args.python} {project_name}", cwd=curdir)Option 2: Detect existing Python version
If a .venv already exists, detect its Python version and preserve it when recreating:
def get_existing_python_version(venv_path):
"""Detect Python version from existing venv if present."""
python_exe = venv_path / "bin" / "python"
if python_exe.exists():
result = subprocess.run([str(python_exe), "--version"],
capture_output=True, text=True)
# Parse version from output
return parse_version(result.stdout)
return None