diff --git a/docs/upgrade-deps-prompt.md b/docs/upgrade-deps-prompt.md new file mode 100644 index 0000000..d185189 --- /dev/null +++ b/docs/upgrade-deps-prompt.md @@ -0,0 +1,105 @@ +# 依赖版本优化流程提示词 + +## 任务概述 + +重新梳理 `scripts/config.py` 中 `DEPENDENCIES` 的版本号和 python 版本。 + +## 核心原则 + +1. **default 的 python 版本始终使用 None**,即默认 python 版本 +2. **实在需要指定 python 版本时**,才在具体的系统依赖(如 Darwin-x86_64)中指定 python 版本,而不是改 default 中的 python 版本 +3. **dependencies 中的依赖都需要指定版本** + - 以当前时间点的最新版本指定 + - 如果最新版本无法满足,才在指定系统依赖中探索能运行的最新依赖版本号 + +## 推荐流程 + +### 阶段 1:规范梳理 + +1. 确定需要检查的依赖列表 +2. 确定版本查询方法(如 PyPI JSON API) +3. 确定测试验证流程 + +### 阶段 2:版本探索(实现阶段) + +1. **先移除所有特定当前平台配置**,只保留 default +2. **default 配置使用最新版本作为标杆** +3. **逐个文件类型测试** + - 先测试 default 配置 + - 若 default 失败,再添加特定平台配置并探索可运行的最新版本 +4. **所有依赖(无论之前是否指定版本)都重新探索** + +### 阶段 3:配置更新 + +1. 修改 `default.python = None` +2. 更新所有依赖到指定版本 +3. 保留/调整特定平台的特殊配置 + +## 关键文件 + +- `scripts/config.py` - DEPENDENCIES 配置 +- `run_tests.py` - 测试运行器(包含 TEST_FIXTURE_DEPENDENCIES) +- `openspec/changes/` - OpenSpec 变更目录 + +## 常用 PyPI 版本查询 + +使用 Python 查询 PyPI 最新版本: + +```python +import json +import urllib.request + +def get_latest_version(package): + try: + url = f'https://pypi.org/pypi/{package}/json' + with urllib.request.urlopen(url, timeout=15) as f: + data = json.load(f) + return data['info']['version'] + except Exception as e: + return f'error: {e}' +``` + +## 本次(2026-03-17)的经验总结 + +### Darwin-x86_64 平台的已知问题 + +1. **torch 无 Darwin-x86_64 wheel**(docling 2.80.0 依赖 torch) + - 解决:使用 docling 2.40.0 + docling-parse 4.0.0 + numpy<2 +2. **onnxruntime 无 Darwin-x86_64 + Python 3.14 wheel**(markitdown 依赖) + - 解决:指定 python 3.12 +3. **pyppeteer 2.0.0 与 selenium 4.41.0 的 urllib3 版本冲突** + - 解决:selenium 降级到 4.25.0 +4. **pandas 3.0.1 与 fixtures 依赖 pandas<3.0.0 冲突** + - 解决:特定平台使用 pandas<3.0.0 + +### 本次更新的依赖版本(截止 2026-03-17) + +| 依赖 | 版本 | +|------|------| +| docling | 2.80.0 (default) / 2.40.0 (Darwin-x86_64) | +| docling-parse | 5.5.0 (default) / 4.0.0 (Darwin-x86_64) | +| unstructured[...] | 0.21.5 | +| markitdown[...] | 0.1.5 | +| pypdf | 6.9.0 | +| markdownify | 1.2.2 | +| pypandoc-binary | 1.17 | +| python-docx | 1.2.0 | +| pandas | 3.0.1 (default) / <3.0.0 (Darwin-x86_64) | +| tabulate | 0.10.0 | +| openpyxl | 3.1.5 | +| python-pptx | 1.0.2 | +| trafilatura | 2.0.0 | +| domscribe | 0.1.3 | +| html2text | 2025.4.15 | +| beautifulsoup4 | 4.14.3 | +| httpx | 0.28.1 | +| chardet | 7.1.0 | +| pyppeteer | 2.0.0 | +| selenium | 4.25.0 (Darwin-x86_64) | +| xlrd | 2.0.2 | +| olefile | 0.47 | +| numpy | <2 (Darwin-x86_64) | + +## 创建 OpenSpec 变更 + +使用 `/opsx:new` 或 `/opsx:ff` 创建变更,使用 spec-driven 工作流。 diff --git a/openspec/specs/multi-platform-dependencies/spec.md b/openspec/specs/multi-platform-dependencies/spec.md index 90b01ce..c2b7374 100644 --- a/openspec/specs/multi-platform-dependencies/spec.md +++ b/openspec/specs/multi-platform-dependencies/spec.md @@ -43,20 +43,17 @@ config.py 中的 DEPENDENCIES 配置使用字典结构,保持简单直接以 - **AND** Darwin-x86_64 配置中不包含 unstructured 相关依赖 ### Requirement: 依赖版本管理 -所有依赖必须指定版本号,default 平台使用截止 2026-03-17 的最新版本,Darwin-x86_64 平台使用已验证可用的版本。 +所有依赖必须指定版本号;default 平台使用截止 2026-03-17 的最新版本作为标杆;default 配置在当前平台测试失败时,在特定平台配置中探索可运行的最新版本;default 配置的 python 版本必须为 None(使用默认 python 版本),仅在特定平台配置中可指定 python 版本。 -#### Scenario: default 平台使用最新版本 -- **WHEN** 查看 config.DEPENDENCIES 中 default 配置的依赖 -- **THEN** 所有依赖都有明确的版本号 -- **AND** docling 使用 2.80.0 -- **AND** docling-parse 使用 5.5.0 -- **AND** markitdown 使用 0.1.5 +#### Scenario: default 平台使用最新版本且 python 为 None +- **WHEN** 查看 config.DEPENDENCIES 中 default 配置 +- **THEN** python 版本为 None +- **AND** 所有依赖都有明确的版本号 +- **AND** 使用截止 2026-03-17 的最新版本 -#### Scenario: Darwin-x86_64 平台使用验证版本 -- **WHEN** 查看 config.DEPENDENCIES 中 Darwin-x86_64 配置的依赖 -- **THEN** docling 使用 2.40.0 -- **AND** docling-parse 使用 4.0.0 -- **AND** numpy 使用 <2 +#### Scenario: 特定平台在 default 失败时探索可运行版本 +- **WHEN** default 配置在当前平台测试失败 +- **THEN** 在特定平台配置中探索可运行的最新版本 ### Requirement: 平台检测文档 系统必须在 `SKILL.md` 中提供平台检测方法和平台特定的安装指南。 diff --git a/scripts/config.py b/scripts/config.py index 00e814d..cbf4a9d 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -24,13 +24,13 @@ class Config: DEPENDENCIES = { "pdf": { "default": { - "python": "3.12", + "python": None, "dependencies": [ "docling==2.80.0", - "unstructured[pdf]", + "unstructured[pdf]==0.21.5", "markitdown[pdf]==0.1.5", "pypdf==6.9.0", - "markdownify==0.13.1" + "markdownify==1.2.2" ] }, "Darwin-x86_64": { @@ -41,20 +41,20 @@ DEPENDENCIES = { "numpy<2", "markitdown[pdf]==0.1.5", "pypdf==6.9.0", - "markdownify==0.13.1" + "markdownify==1.2.2" ] } }, "docx": { "default": { - "python": "3.12", + "python": None, "dependencies": [ "docling==2.80.0", - "unstructured[docx]", + "unstructured[docx]==0.21.5", "markitdown[docx]==0.1.5", - "pypandoc-binary==1.13", + "pypandoc-binary==1.17", "python-docx==1.2.0", - "markdownify==0.13.1" + "markdownify==1.2.2" ] }, "Darwin-x86_64": { @@ -64,21 +64,21 @@ DEPENDENCIES = { "docling-parse==4.0.0", "numpy<2", "markitdown[docx]==0.1.5", - "pypandoc-binary==1.13", + "pypandoc-binary==1.17", "python-docx==1.2.0", - "markdownify==0.13.1" + "markdownify==1.2.2" ] } }, "xlsx": { "default": { - "python": "3.12", + "python": None, "dependencies": [ "docling==2.80.0", - "unstructured[xlsx]", + "unstructured[xlsx]==0.21.5", "markitdown[xlsx]==0.1.5", "pandas==3.0.1", - "tabulate==0.9.0", + "tabulate==0.10.0", "openpyxl==3.1.5" ] }, @@ -90,20 +90,20 @@ DEPENDENCIES = { "numpy<2", "markitdown[xlsx]==0.1.5", "pandas<3.0.0", - "tabulate==0.9.0", + "tabulate==0.10.0", "openpyxl==3.1.5" ] } }, "pptx": { "default": { - "python": "3.12", + "python": None, "dependencies": [ "docling==2.80.0", - "unstructured[pptx]", + "unstructured[pptx]==0.21.5", "markitdown[pptx]==0.1.5", "python-pptx==1.0.2", - "markdownify==0.13.1" + "markdownify==1.2.2" ] }, "Darwin-x86_64": { @@ -114,21 +114,35 @@ DEPENDENCIES = { "numpy<2", "markitdown[pptx]==0.1.5", "python-pptx==1.0.2", - "markdownify==0.13.1" + "markdownify==1.2.2" ] } }, "html": { "default": { - "python": "3.12", + "python": None, "dependencies": [ - "trafilatura==1.12.2", - "domscribe", + "trafilatura==2.0.0", + "domscribe==0.1.3", "markitdown==0.1.5", - "html2text==2024.2.26", + "html2text==2025.4.15", "beautifulsoup4==4.14.3", "httpx==0.28.1", - "chardet==5.2.0", + "chardet==7.1.0", + "pyppeteer==2.0.0", + "selenium==4.25.0" + ] + }, + "Darwin-x86_64": { + "python": "3.12", + "dependencies": [ + "trafilatura==2.0.0", + "domscribe==0.1.3", + "markitdown==0.1.5", + "html2text==2025.4.15", + "beautifulsoup4==4.14.3", + "httpx==0.28.1", + "chardet==7.1.0", "pyppeteer==2.0.0", "selenium==4.25.0" ] @@ -136,13 +150,13 @@ DEPENDENCIES = { }, "xls": { "default": { - "python": "3.12", + "python": None, "dependencies": [ - "unstructured[xlsx]", + "unstructured[xlsx]==0.21.5", "markitdown[xls]==0.1.5", "pandas==3.0.1", - "tabulate==0.9.0", - "xlrd==2.0.1", + "tabulate==0.10.0", + "xlrd==2.0.2", "olefile==0.47" ] }, @@ -151,8 +165,8 @@ DEPENDENCIES = { "dependencies": [ "markitdown[xls]==0.1.5", "pandas<3.0.0", - "tabulate==0.9.0", - "xlrd==2.0.1", + "tabulate==0.10.0", + "xlrd==2.0.2", "olefile==0.47", "openpyxl==3.1.5" ] @@ -160,19 +174,19 @@ DEPENDENCIES = { }, "doc": { "default": { - "python": "3.12", + "python": None, "dependencies": [] } }, "ppt": { "default": { - "python": "3.12", + "python": None, "dependencies": [ "docling==2.80.0", - "unstructured[pptx]", + "unstructured[pptx]==0.21.5", "markitdown[pptx]==0.1.5", "python-pptx==1.0.2", - "markdownify==0.13.1", + "markdownify==1.2.2", "olefile==0.47" ] }, @@ -184,7 +198,7 @@ DEPENDENCIES = { "numpy<2", "markitdown[pptx]==0.1.5", "python-pptx==1.0.2", - "markdownify==0.13.1", + "markdownify==1.2.2", "olefile==0.47" ] } diff --git a/tests/test_core/test_advice_generator.py b/tests/test_core/test_advice_generator.py index 7e207b7..08675d5 100644 --- a/tests/test_core/test_advice_generator.py +++ b/tests/test_core/test_advice_generator.py @@ -68,7 +68,7 @@ class TestGetDependencies: def test_get_default_dependencies(self): """测试获取默认依赖配置。""" python_ver, deps = get_dependencies(DocxReader, "Unknown-Platform") - assert python_ver == "3.12" + assert python_ver is None assert len(deps) > 0 # 检查是否有 docling 相关依赖(可能带版本号) assert any(dep.startswith("docling") for dep in deps) @@ -76,14 +76,14 @@ class TestGetDependencies: def test_get_pdf_dependencies(self): """测试获取 PDF 依赖。""" python_ver, deps = get_dependencies(PdfReader, "Darwin-arm64") - assert python_ver == "3.12" + assert python_ver is None # 检查是否有 docling 相关依赖(可能带版本号) assert any(dep.startswith("docling") for dep in deps) def test_get_html_dependencies(self): """测试获取 HTML 依赖。""" python_ver, deps = get_dependencies(HtmlReader, "Linux-x86_64") - assert python_ver == "3.12" + assert python_ver is None # 检查是否有 trafilatura 相关依赖(可能带版本号) assert any(dep.startswith("trafilatura") for dep in deps)