Skip to content

Commit 022a556

Browse files
authored
Merge pull request #30 from XpressAI/fahreza/init-agent-python
✨ Add `--python` option to `xaibo init` command
2 parents 8be8685 + 0e7651a commit 022a556

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

docs/reference/cli.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ Initialize a new Xaibo project with recommended structure.
1111
### Syntax
1212

1313
```bash
14-
uvx xaibo init <project_name>
14+
uvx xaibo init <project_name> [--python <version>]
1515
```
1616

1717
### Parameters
1818

1919
| Parameter | Type | Required | Description |
2020
|-----------|------|----------|-------------|
2121
| `project_name` | `str` | Yes | Name of the project directory to create |
22+
| `--python` | `str` | No | Python version to use (e.g., `3.11`, `3.12`, `3.13`). If not specified, uv will use the version from `.python-version` file, or the first Python found on PATH |
2223

2324
### Generated Structure
2425

@@ -42,6 +43,9 @@ project_name/
4243
# Create a new project
4344
uvx xaibo init my_agent_project
4445

46+
# Create a new project with specific Python version
47+
uvx xaibo init my_agent_project --python 3.12
48+
4549
# Navigate to project
4650
cd my_agent_project
4751

src/xaibo/cli/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,12 @@ def init(args, extra_args=[]):
319319
project_name = args.project_name
320320
curdir = Path(os.getcwd())
321321
project_dir = curdir / project_name
322-
universal_run(f"uv init --bare {project_name}", cwd=curdir)
322+
323+
# Build uv init command with optional python version
324+
uv_init_cmd = f"uv init --bare {project_name}"
325+
if args.python:
326+
uv_init_cmd += f" --python {args.python}"
327+
universal_run(uv_init_cmd, cwd=curdir)
323328
universal_run(f"uv add xaibo xaibo[{','.join(modules)}] pytest", cwd=project_dir)
324329

325330
(project_dir / "agents").mkdir()
@@ -509,6 +514,8 @@ def main():
509514
# 'init' command.
510515
init_parser = subparsers.add_parser('init', help='Initialize a Xaibo project')
511516
init_parser.add_argument('project_name', type=str, help='Name of the project')
517+
init_parser.add_argument('--python', type=str, default=None,
518+
help='Python version to use (e.g., 3.11, 3.12, 3.13). If not specified, uv will use the version from .python-version file, or the first Python found on PATH.')
512519
init_parser.set_defaults(func=init)
513520

514521
# 'eject' command

0 commit comments

Comments
 (0)