Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

Validate resolved dependency Python metadata independently

myhlolia63acd74f21c
diff --git a/.github/workflows/transformers5.yml b/.github/workflows/transformers5.yml
index 491c15e1..4e5b7c67 100644
--- a/.github/workflows/transformers5.yml
+++ b/.github/workflows/transformers5.yml
@@ -72,6 +72,7 @@ jobs:
python -m pytest -q -o addopts='' \
tests/unittest/test_transformers5_models.py \
tests/unittest/test_transformers5_runtime.py \
+ tests/unittest/test_dependency_compatibility_check.py \
tests/unittest/test_pp_doclayoutv2_postprocess.py \
tests/unittest/test_mfr_latex_utils.py \
tests/unittest/test_vlm_config.py \
@@ -111,8 +112,19 @@ jobs:
--docvortex-wheel dependency-wheels/docvortex-*.whl --utils-matrix --check-wheels \
--platform '${{ matrix.platform }}' --transformers '${{ matrix.transformers }}' \
--output dependency-matrix.json
+ - name: Reject unsupported vLLM 0.19.1 on Python 3.14
+ if: matrix.platform == 'linux' && matrix.transformers == '5.16.1'
+ run: |
+ python scripts/check_transformers5_dependencies.py \
+ --mineru-wheel dist/*.whl --utils-wheel dependency-wheels/mineru_vl_utils-*.whl \
+ --docvortex-wheel dependency-wheels/docvortex-*.whl \
+ --platform linux --python 3.14 --extras full \
+ --requirement 'vllm==0.19.1' --expect-failure --check-wheels \
+ --output vllm-python314-rejection.json
- uses: actions/upload-artifact@v6
if: always()
with:
name: dependencies-${{ matrix.platform }}-${{ matrix.transformers }}
- path: dependency-matrix.json
+ path: |
+ dependency-matrix.json
+ vllm-python314-rejection.json
diff --git a/scripts/check_transformers5_dependencies.py b/scripts/check_transformers5_dependencies.py
index 2dc47864..06d49e38 100644
--- a/scripts/check_transformers5_dependencies.py
+++ b/scripts/check_transformers5_dependencies.py
@@ -45,8 +45,8 @@ def target_tags(platform: str, python: str) -> set:
)
-def verify_wheels(resolution: str, platform: str, python: str, cache: Path) -> list[str]:
- """检查每个已解析发布包的 Python 范围及 wheel;只允许已知纯 Python jieba 从源码安装。"""
+def verify_wheels(resolution: str, platform: str, python: str, cache: Path, *, check_wheels: bool) -> list[str]:
+ """始终检查发布包的 Python 范围,按开关检查 wheel;只允许纯 Python jieba 从源码安装。"""
tags = target_tags(platform, python)
failures = []
cache.mkdir(parents=True, exist_ok=True)
@@ -66,7 +66,7 @@ def verify_wheels(resolution: str, platform: str, python: str, cache: Path) -> l
requires_python = data["info"].get("requires_python")
if requires_python and python not in SpecifierSet(requires_python):
failures.append(f"{name}=={version}: Python {python} excluded by {requires_python}")
- available = any(
+ available = not check_wheels or any(
item["filename"].endswith(".whl") and bool(parse_wheel_filename(item["filename"])[3] & tags)
for item in data["urls"]
)
@@ -150,10 +150,15 @@ def main() -> None:
checks += [f"forbidden dependency: {name}" for name in selected & FORBIDDEN]
if extra == "base" and not args.requirement:
checks += [f"heavy base dependency: {name}" for name in selected & {"torch", "transformers"}]
- if args.check_wheels:
- checks += verify_wheels(process.stdout, args.platform, python, args.output.parent / "pypi-metadata")
- rejection_confirmed = bool(invalid_roots) or "No solution found" in process.stderr
- success = (not resolved and rejection_confirmed if expected_failure else resolved) and not checks
+ compatibility_errors = verify_wheels(
+ process.stdout, args.platform, python, args.output.parent / "pypi-metadata", check_wheels=args.check_wheels
+ )
+ checks += compatibility_errors
+ resolved = resolved and not compatibility_errors
+ else:
+ compatibility_errors = []
+ rejection_confirmed = bool(invalid_roots or compatibility_errors) or "No solution found" in process.stderr
+ success = not resolved and rejection_confirmed if expected_failure else resolved and not checks
records.append(
{
"package": package,
@@ -162,6 +167,7 @@ def main() -> None:
"success": success,
"expected_failure": expected_failure,
"resolved": resolved,
+ "resolver_succeeded": process.returncode == 0,
"invalid_roots": invalid_roots,
"wheel_or_dependency_errors": checks,
"resolution": process.stdout,
diff --git a/tests/unittest/test_dependency_compatibility_check.py b/tests/unittest/test_dependency_compatibility_check.py
new file mode 100644
index 00000000..cc9ca0b6
--- /dev/null
+++ b/tests/unittest/test_dependency_compatibility_check.py
@@ -0,0 +1,24 @@
+"""验证解析成功不能绕过发布包的 Python 和二进制支持声明。"""
+import json
+from pathlib import Path
+
+from scripts.check_transformers5_dependencies import verify_wheels
+
+
+def test_python_metadata_is_checked_without_binary_wheel_option(tmp_path: Path) -> None:
+ """模拟求解器放过旧包的情况,即使不查 wheel 也必须拒绝超出声明的 Python。"""
+ metadata = {"info": {"requires_python": ">=3.10,<3.14"}, "urls": [{"filename": "sample-1.0-py3-none-any.whl"}]}
+ (tmp_path / "sample-1.0.json").write_text(json.dumps(metadata))
+ errors = verify_wheels("sample==1.0", "linux", "3.14", tmp_path, check_wheels=False)
+ assert len(errors) == 1
+ assert "Python 3.14 excluded" in errors[0]
+
+
+def test_binary_wheel_check_uses_target_python_and_platform(tmp_path: Path) -> None:
+ """其他平台的旧 ABI wheel 不能冒充目标环境的可安装发行文件。"""
+ metadata = {"info": {"requires_python": ">=3.10"}, "urls": [{"filename": "sample-1.0-cp313-cp313-win_amd64.whl"}]}
+ (tmp_path / "sample-1.0.json").write_text(json.dumps(metadata))
+ assert not verify_wheels("sample==1.0", "linux", "3.14", tmp_path, check_wheels=False)
+ errors = verify_wheels("sample==1.0", "linux", "3.14", tmp_path, check_wheels=True)
+ assert len(errors) == 1
+ assert "no wheel for linux Python 3.14" in errors[0]