docs: 移除 pyproject.toml,改为 uv run --with 依赖管理方式
- 移除 pyproject.toml 和 uv.lock - 更新 SKILL.md:使用 uv run --with 按需加载依赖 - 更新 README.md:添加多行格式的测试命令 - 更新项目规范文档 - 修复脚本:支持从任意位置执行 - 新增 uv-with-dependency-management 规范
This commit is contained in:
146
README.md
146
README.md
@@ -4,13 +4,9 @@
|
||||
|
||||
## 开发环境
|
||||
|
||||
- 使用 uv 管理依赖,禁用主机 Python
|
||||
- 依赖声明:pyproject.toml
|
||||
- 安装:根据平台选择对应的 extras(详见 SKILL.md)
|
||||
- macOS x86_64 (Intel): `uv pip install -e ".[pdf-macos-intel]"`
|
||||
- macOS arm64 (Apple Silicon): `uv pip install -e ".[pdf-macos-arm]"`
|
||||
- Windows: `uv pip install -e ".[pdf-win]"`
|
||||
- Linux: `uv pip install -e ".[pdf-linux]"`
|
||||
- 使用 uv 运行脚本和测试,禁用主机 Python
|
||||
- 依赖管理:使用 `uv run --with` 按需加载依赖
|
||||
- 依赖说明:详见 SKILL.md 的"依赖安装指南"章节
|
||||
|
||||
## 项目结构
|
||||
|
||||
@@ -26,25 +22,128 @@ skill/ # SKILL 文档
|
||||
|
||||
## 开发工作流
|
||||
|
||||
使用 `uv run --with` 方式运行测试和开发工具:
|
||||
|
||||
```bash
|
||||
# 运行测试
|
||||
uv run pytest
|
||||
# 运行测试(需要先安装 pytest)
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with pytest-cov \
|
||||
--with chardet \
|
||||
pytest
|
||||
|
||||
# 运行测试并查看覆盖率
|
||||
uv run pytest --cov=scripts --cov-report=term-missing
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with pytest-cov \
|
||||
--with chardet \
|
||||
pytest --cov=scripts --cov-report=term-missing
|
||||
|
||||
# 运行特定测试文件
|
||||
uv run pytest tests/test_readers/test_docx/
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with chardet \
|
||||
pytest tests/test_readers/test_docx/
|
||||
|
||||
# 运行特定测试类或方法
|
||||
uv run pytest tests/test_cli/test_main.py::TestCLIDefaultOutput::test_default_output_docx
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with chardet \
|
||||
pytest tests/test_cli/test_main.py::TestCLIDefaultOutput::test_default_output_docx
|
||||
|
||||
# 代码格式化
|
||||
uv run black .
|
||||
uv run isort .
|
||||
uv run \
|
||||
--with black \
|
||||
--with isort \
|
||||
--with chardet \
|
||||
bash -c "black . && isort ."
|
||||
|
||||
# 类型检查
|
||||
uv run mypy .
|
||||
uv run \
|
||||
--with mypy \
|
||||
--with chardet \
|
||||
mypy .
|
||||
```
|
||||
|
||||
**测试 DOCX reader**:
|
||||
|
||||
```bash
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with docling \
|
||||
--with "unstructured[docx]" \
|
||||
--with "markitdown[docx]" \
|
||||
--with pypandoc-binary \
|
||||
--with python-docx \
|
||||
--with markdownify \
|
||||
--with chardet \
|
||||
pytest tests/test_readers/test_docx/
|
||||
```
|
||||
|
||||
**测试 PDF reader**:
|
||||
|
||||
```bash
|
||||
# 默认命令(macOS ARM、Linux、Windows)
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with docling \
|
||||
--with "unstructured[pdf]" \
|
||||
--with "markitdown[pdf]" \
|
||||
--with pypdf \
|
||||
--with markdownify \
|
||||
--with chardet \
|
||||
pytest tests/test_readers/test_pdf/
|
||||
|
||||
# macOS x86_64 (Intel) 特殊命令
|
||||
uv run \
|
||||
--python 3.12 \
|
||||
--with pytest \
|
||||
--with "docling==2.40.0" \
|
||||
--with "docling-parse==4.0.0" \
|
||||
--with "numpy<2" \
|
||||
--with "markitdown[pdf]" \
|
||||
--with pypdf \
|
||||
--with markdownify \
|
||||
--with chardet \
|
||||
pytest tests/test_readers/test_pdf/
|
||||
```
|
||||
|
||||
**测试其他格式**:
|
||||
|
||||
```bash
|
||||
# XLSX reader
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with docling \
|
||||
--with "unstructured[xlsx]" \
|
||||
--with "markitdown[xlsx]" \
|
||||
--with pandas \
|
||||
--with tabulate \
|
||||
--with chardet \
|
||||
pytest tests/test_readers/test_xlsx/
|
||||
|
||||
# PPTX reader
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with docling \
|
||||
--with "unstructured[pptx]" \
|
||||
--with "markitdown[pptx]" \
|
||||
--with python-pptx \
|
||||
--with markdownify \
|
||||
--with chardet \
|
||||
pytest tests/test_readers/test_pptx/
|
||||
|
||||
# HTML reader
|
||||
uv run \
|
||||
--with pytest \
|
||||
--with trafilatura \
|
||||
--with domscribe \
|
||||
--with markitdown \
|
||||
--with html2text \
|
||||
--with beautifulsoup4 \
|
||||
--with httpx \
|
||||
--with chardet \
|
||||
pytest tests/test_readers/test_html/
|
||||
```
|
||||
|
||||
## 测试
|
||||
@@ -61,13 +160,8 @@ uv run mypy .
|
||||
- 编码测试(GBK、UTF-8 BOM 等)
|
||||
- 一致性测试(验证不同 Reader 解析结果的一致性)
|
||||
|
||||
运行测试前确保已安装所有依赖(根据你的平台选择对应的 extras):
|
||||
```bash
|
||||
# macOS x86_64 (Intel) 示例
|
||||
uv pip install -e ".[office-macos-intel]"
|
||||
运行测试前,请根据测试类型使用 `uv run --with` 安装对应的依赖包。详见上方的"开发工作流"章节和 SKILL.md 的"依赖安装指南"。
|
||||
|
||||
# 其他平台请参考 SKILL.md 的"多平台依赖安装指南"
|
||||
```
|
||||
|
||||
## 代码规范
|
||||
|
||||
@@ -98,16 +192,12 @@ skill/SKILL.md 面向 AI 用户,必须遵循 Claude Skill 构建指南的最
|
||||
6. **错误处理**: 常见错误及解决方案
|
||||
7. **References**: 指向项目文档的链接
|
||||
|
||||
### 双路径执行策略
|
||||
|
||||
- **优先**: 使用 lyxy-runner-python skill(自动管理依赖)
|
||||
- **回退**: 主机 Python 环境(需手动安装依赖)
|
||||
|
||||
### 依赖说明
|
||||
### 依赖管理
|
||||
|
||||
- 使用 `uv run --with` 方式按需加载依赖
|
||||
- 必须使用具体的 pip 包名
|
||||
- 不能使用 lyxy-document[xxx] 形式(发布时没有 pyproject.toml)
|
||||
- 按文档类型分组说明
|
||||
- 详见 SKILL.md 的"依赖安装指南"章节
|
||||
|
||||
## 解析器架构
|
||||
|
||||
|
||||
Reference in New Issue
Block a user