Skip to content

Commit 5ca3bf2

Browse files
authored
feat: 新增脚本支持在 uv 安装方式在 macOS 上运行,更新相关安装文档和README文档 (#203)
1 parent f2a34ff commit 5ca3bf2

7 files changed

Lines changed: 151 additions & 5 deletions

File tree

INSTALL.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,42 @@ source .venv/bin/activate # Linux / macOS
8484
pip install -e .
8585
```
8686

87+
### uv Installation
88+
89+
[uv](https://docs.astral.sh/uv/) manages the Python toolchain, virtual environment and dependencies based on the repository's `pyproject.toml` for fast, reproducible installs. This project provides a script for one-shot setup on macOS:
90+
91+
```bash
92+
git clone https://github.com/trpc-group/trpc-agent-python.git
93+
cd trpc-agent-python
94+
95+
# Install uv on macOS (see https://docs.astral.sh/uv/getting-started/installation/)
96+
curl -LsSf https://astral.sh/uv/install.sh | sh
97+
98+
# One-shot setup
99+
bash build_mac_uv.sh
100+
101+
# add optional extras
102+
EXTRAS="a2a knowledge" bash build_mac_uv.sh
103+
```
104+
105+
Or run the steps manually:
106+
107+
```bash
108+
uv venv --python-preference only-system # use the local Python
109+
uv sync --extra dev # core + dev tooling
110+
uv sync --extra a2a --extra knowledge # add optional extras
111+
uv sync # production install (core only)
112+
113+
# Run commands inside the environment without activating it for evaluation
114+
uv run python -c "from trpc_agent_sdk.version import __version__; print(__version__)"
115+
```
116+
117+
To speed up downloads via a mirror, pass `--default-index`, e.g.:
118+
119+
```bash
120+
uv sync --default-index https://mirrors.cloud.tencent.com/pypi/simple
121+
```
122+
87123
### Optional Dependencies Reference
88124

89125
| Extension | Purpose | Install Command |

INSTALL.zh_CN.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,42 @@ source .venv/bin/activate # Linux / macOS
8484
pip install -e .
8585
```
8686

87+
### uv 安装
88+
89+
[uv](https://docs.astral.sh/uv/) 会基于仓库中 `pyproject.toml` 管理 Python 工具链、虚拟环境与依赖,实现快速、可复现的安装,本项目提供脚本在 macOS 上一键安装运行:
90+
91+
```bash
92+
git clone https://github.com/trpc-group/trpc-agent-python.git
93+
cd trpc-agent-python
94+
95+
# 在 macOS 上安装 uv(参考 https://docs.astral.sh/uv/getting-started/installation/)
96+
curl -LsSf https://astral.sh/uv/install.sh | sh
97+
98+
# 一键初始化核心依赖
99+
bash build_mac_uv.sh
100+
101+
# 按需追加可选扩展
102+
EXTRAS="a2a knowledge" bash build_mac_uv.sh
103+
```
104+
105+
或者使用手动执行的方式:
106+
107+
```bash
108+
uv venv --python-preference only-system # 使用本地已安装的 Python
109+
uv sync --extra dev # 核心依赖 + 开发工具
110+
uv sync --extra a2a --extra knowledge # 按需追加可选扩展
111+
uv sync # 生产安装(仅核心依赖)
112+
113+
# 无需激活环境即可运行命令验证
114+
uv run python -c "from trpc_agent_sdk.version import __version__; print(__version__)"
115+
```
116+
117+
如需使用国内镜像加速,可传入 `--default-index`,例如:
118+
119+
```bash
120+
uv sync --default-index https://mirrors.cloud.tencent.com/pypi/simple
121+
```
122+
87123
### 可选依赖对照表
88124

89125
| 扩展名 | 用途 | 安装命令 |

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ tRPC-Agent-Python provides an end-to-end foundation for agent building, orchestr
7777

7878
### Installation
7979

80+
#### Install with pip
81+
8082
```bash
8183
pip install trpc-agent-py
8284
```
@@ -87,6 +89,33 @@ Install optional capabilities as needed:
8789
pip install "trpc-agent-py[a2a,ag-ui,knowledge,agent-claude,mem0,mempalace,langfuse]"
8890
```
8991

92+
#### Install with uv
93+
94+
[uv](https://docs.astral.sh/uv/) provides fast, reproducible installs:
95+
96+
```bash
97+
uv venv --python-preference only-system # use the local Python
98+
uv sync # production install (core only)
99+
uv sync --extra dev # core + dev tooling
100+
uv sync --extra a2a --extra knowledge # add optional extras
101+
102+
103+
# Run commands inside the environment without activating it for evaluation
104+
uv run python -c "from trpc_agent_sdk.version import __version__; print(__version__)"
105+
```
106+
107+
This project also provides a script for one-shot setup on macOS:
108+
```bash
109+
# One-shot setup
110+
bash build_mac_uv.sh
111+
```
112+
113+
Install optional capabilities as needed:
114+
115+
```bash
116+
EXTRAS="a2a knowledge" bash build_mac_uv.sh
117+
```
118+
90119
### Develop Weather Agent
91120

92121
```python

build_mac_uv.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
#
3+
# uv-based development setup for trpc-agent-python (macOS).
4+
#
5+
# This is a standalone alternative to build_mac.sh (which uses pip).
6+
# It uses uv to manage the Python toolchain, virtualenv and dependencies.
7+
#
8+
# Usage:
9+
# bash build_mac_uv.sh # core + dev extra
10+
# EXTRAS="a2a knowledge" bash build_mac_uv.sh # also install extras
11+
#
12+
set -euo pipefail
13+
14+
# Make sure uv's default install location is on PATH before probing for uv,
15+
# so a previously installed uv is reused instead of reinstalled every run.
16+
export PATH="$HOME/.local/bin:$PATH"
17+
18+
# 1. Ensure uv is available.
19+
if ! command -v uv >/dev/null 2>&1; then
20+
echo "[build_mac_uv] uv not found, installing..."
21+
curl -LsSf https://astral.sh/uv/install.sh | sh
22+
export PATH="$HOME/.local/bin:$PATH"
23+
fi
24+
25+
echo "[build_mac_uv] uv version: $(uv --version)"
26+
27+
# 2. Create the virtual environment using the user's local Python.
28+
uv venv --python-preference only-system
29+
30+
# 3. Sync dependencies: core + the `dev` extra, plus any requested extras.
31+
EXTRA_ARGS=()
32+
for e in ${EXTRAS:-}; do
33+
EXTRA_ARGS+=("--extra" "$e")
34+
done
35+
uv sync --extra dev ${EXTRA_ARGS[@]+"${EXTRA_ARGS[@]}"}
36+
37+
# 4. Smoke test the installation.
38+
uv run python -c "import trpc_agent_sdk; from trpc_agent_sdk.version import __version__; print(f'trpc-agent-py {__version__} installed via uv')"
39+
40+
echo "[build_mac_uv] Done. Activate the env with: source .venv/bin/activate"

docs/mkdocs/en/openclaw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ flowchart TD
4444

4545
### 1) Environment Preparation
4646

47-
- Python `>=3.10` (recommended `3.12`)
47+
- Python `>=3.11` (recommended `3.12`; requires `nanobot-ai`)
4848
- Use a virtual environment (`uv` or `venv`)
4949

5050
```bash

docs/mkdocs/zh/openclaw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ flowchart TD
4444

4545
### 1) 环境准备
4646

47-
- Python `>=3.10`(推荐 `3.12`
47+
- Python `>=3.11`(推荐 `3.12`;依赖 `nanobot-ai`
4848
- 建议使用虚拟环境(`uv``venv`
4949

5050
```bash

pyproject.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ langfuse=[
6666
"opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.28.0",
6767
]
6868
openclaw = [
69-
"nanobot-ai>=0.1.4.post5",
69+
"nanobot-ai>=0.1.4.post5; python_full_version >= '3.11'",
7070
"aiofiles",
7171
"wecom-aibot-sdk-python>=0.1.5",
7272
]
@@ -151,7 +151,7 @@ all = [
151151
"mem0ai>=1.0.3",
152152
"mempalace>=3.3.3",
153153
"typer>=0.9.0",
154-
"nanobot-ai>=0.1.4.post6",
154+
"nanobot-ai>=0.1.4.post6; python_full_version >= '3.11'",
155155
"aiofiles",
156156
"wecom-aibot-sdk-python>=0.1.5",
157157
"a2a-sdk<1.0.0,>=0.3.22",
@@ -172,7 +172,12 @@ Homepage = "https://github.com/trpc-group/trpc-agent-python.git"
172172
Documentation = "https://github.com/trpc-group/trpc-agent-python.git"
173173
Repository = "https://github.com/trpc-group/trpc-agent-python.git"
174174

175-
175+
# uv project configuration. Defaults to the public PyPI index; the project is
176+
# installed as an editable package.
177+
[tool.uv]
178+
package = true
179+
# Keep uv aligned with the package-level Python support. Optional dependencies
180+
# that require a newer interpreter use dependency-level markers above.
176181

177182
# 可选:添加工具配置
178183
[tool.black]

0 commit comments

Comments
 (0)