Skip to content

Commit 9c7fb11

Browse files
author
liangyz
committed
chore: update project configuration and documentation
- Add 'dist/' to .gitignore to exclude build artifacts. - Rename entry point from 'feishu-agent' to 'lark-agent' in pyproject.toml. - Introduce a new installation guide document for the Lark Agent, detailing packaging and installation methods.
1 parent c834028 commit 9c7fb11

File tree

3 files changed

+213
-2
lines changed

3 files changed

+213
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ __pycache__/
55
.pytest_cache/
66
.env
77
.vscode/
8-
.serena/
8+
.serena/
9+
dist/

doc/打包编译指南.md

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
# Lark Agent 打包编译指南
2+
3+
## 📦 打包方式
4+
5+
### 方式一:构建 Wheel 包(推荐)
6+
7+
使用 `uv` 构建分发包:
8+
9+
```bash
10+
# 构建 wheel 包
11+
uv build
12+
13+
# 构建结果会在 dist/ 目录下
14+
# 例如: dist/lark_agent-0.1.0-py3-none-any.whl
15+
```
16+
17+
### 方式二:构建源码分发包
18+
19+
```bash
20+
# 构建源码分发包(sdist)
21+
uv build --sdist
22+
23+
# 构建结果会在 dist/ 目录下
24+
# 例如: dist/lark-agent-0.1.0.tar.gz
25+
```
26+
27+
### 方式三:同时构建 wheel 和 sdist
28+
29+
```bash
30+
# 构建所有格式的分发包
31+
uv build
32+
33+
# 这会同时生成 wheel 和 sdist
34+
```
35+
36+
---
37+
38+
## 🚀 安装方式
39+
40+
### 从本地构建的包安装
41+
42+
```bash
43+
# 安装本地构建的 wheel 包
44+
uv tool install dist/lark_agent-0.1.0-py3-none-any.whl
45+
46+
# 或从源码安装
47+
uv tool install dist/lark-agent-0.1.0.tar.gz
48+
```
49+
50+
### 从 Git 仓库安装(发布后)
51+
52+
```bash
53+
# 从 GitHub 安装
54+
uv tool install --from git+https://github.com/Wulnut/feishu_agent lark-agent
55+
56+
# 安装特定版本/tag
57+
uv tool install --from git+https://github.com/Wulnut/feishu_agent@v0.1.0 lark-agent
58+
```
59+
60+
---
61+
62+
## 🔧 开发模式安装
63+
64+
### 可编辑安装(开发时使用)
65+
66+
```bash
67+
# 在当前环境中以可编辑模式安装
68+
uv pip install -e .
69+
70+
# 这样修改代码后无需重新安装即可生效
71+
```
72+
73+
---
74+
75+
## 📋 构建前检查清单
76+
77+
1.**版本号**: 确认 `pyproject.toml` 中的版本号正确
78+
2.**依赖**: 确认所有依赖都已正确声明
79+
3.**入口点**: 确认 `[project.scripts]` 配置正确
80+
4.**测试**: 运行测试确保代码正常
81+
```bash
82+
uv run pytest
83+
```
84+
5.**代码质量**: 运行 lint 检查
85+
```bash
86+
uv run ruff check .
87+
```
88+
89+
---
90+
91+
## 🎯 完整发布流程
92+
93+
### 1. 更新版本号
94+
95+
编辑 `pyproject.toml`:
96+
```toml
97+
[project]
98+
version = "0.1.0" # 更新为新版本
99+
```
100+
101+
### 2. 提交更改
102+
103+
```bash
104+
git add .
105+
git commit -m "chore: bump version to 0.1.0"
106+
```
107+
108+
### 3. 创建 Git Tag
109+
110+
```bash
111+
git tag -a v0.1.0 -m "Release v0.1.0"
112+
```
113+
114+
### 4. 构建分发包
115+
116+
```bash
117+
# 清理旧的构建文件
118+
rm -rf dist/ build/ *.egg-info
119+
120+
# 构建新包
121+
uv build
122+
```
123+
124+
### 5. 验证构建结果
125+
126+
```bash
127+
# 查看构建的文件
128+
ls -lh dist/
129+
130+
# 应该看到类似:
131+
# lark_agent-0.1.0-py3-none-any.whl
132+
# lark-agent-0.1.0.tar.gz
133+
```
134+
135+
### 6. 测试安装
136+
137+
```bash
138+
# 在临时环境中测试安装
139+
uv tool install dist/lark_agent-0.1.0-py3-none-any.whl
140+
141+
# 测试命令是否可用
142+
lark-agent --version # 如果支持的话
143+
```
144+
145+
### 7. 推送到远程仓库
146+
147+
```bash
148+
# 推送代码和 tag
149+
git push origin main
150+
git push origin v0.1.0
151+
```
152+
153+
---
154+
155+
## 📦 发布到 PyPI(可选)
156+
157+
如果需要发布到 PyPI:
158+
159+
```bash
160+
# 安装构建工具
161+
uv pip install build twine
162+
163+
# 构建包
164+
uv build
165+
166+
# 上传到 PyPI(需要先配置 credentials)
167+
twine upload dist/*
168+
```
169+
170+
---
171+
172+
## 🔍 验证安装
173+
174+
安装后验证:
175+
176+
```bash
177+
# 检查命令是否可用
178+
which lark-agent
179+
180+
# 检查 Python 模块是否可导入
181+
python -c "from src.mcp_server import main; print('✓ OK')"
182+
```
183+
184+
---
185+
186+
## ⚠️ 注意事项
187+
188+
1. **构建系统**: 确保 `hatchling` 已正确配置在 `[build-system]`
189+
2. **包结构**: 确保 `[tool.hatch.build.targets.wheel]` 中指定的包路径正确
190+
3. **依赖锁定**: 如果使用 `uv.lock`,确保锁定文件是最新的
191+
4. **版本号**: 遵循语义化版本规范(Semantic Versioning)
192+
193+
---
194+
195+
## 🐛 常见问题
196+
197+
### 问题:构建失败,提示找不到包
198+
199+
**解决方案**: 检查 `[tool.hatch.build.targets.wheel]` 配置,确保 `packages = ["src"]` 正确
200+
201+
### 问题:安装后命令不可用
202+
203+
**解决方案**:
204+
- 检查 `[project.scripts]` 配置
205+
- 确保 `~/.local/bin` 在 PATH 中(Linux/macOS)
206+
- 确保 `%USERPROFILE%\.local\bin` 在 PATH 中(Windows)
207+
208+
### 问题:导入模块失败
209+
210+
**解决方案**: 检查 `src/` 目录结构,确保所有 `__init__.py` 文件存在

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
]
1818

1919
[project.scripts]
20-
feishu-agent = "src.mcp_server:main"
20+
lark-agent = "src.mcp_server:main"
2121

2222
[dependency-groups]
2323
dev = [

0 commit comments

Comments
 (0)