feat: add runtime dependency preflight to PDF pipeline#86
Merged
Conversation
283f936 to
7fb2c7e
Compare
md_to_pdf.py now checks for markdown, nh3, and playwright at entry rather than failing deep in a subprocess with ModuleNotFoundError. When a dependency is missing, the script prints an actionable fix command instead of a raw Python traceback.
7fb2c7e to
7b5d49d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Closes #80 — 当前
md_to_pdf.py在下游子进程(markdown_to_html.py/render_pdf.py)依赖缺失时,只抛ModuleNotFoundError,错误信息不友好。修改
scripts/md_to_pdf.pymain()入口检查markdown、nh3、playwright是否可 import,缺失时输出带绝对路径的pip install命令。sync_playwright()+p.chromium.launch()做真正的浏览器可用性检查,捕获 "Executable doesn't exist" 异常时输出playwright install chromium。不再手写缓存路径判断(消除 stale 目录 / 版本不匹配 / headless_shell 差异 / XDG_CACHE_HOME / LOCALAPPDATA / PLAYWRIGHT_BROWSERS_PATH=0 等问题)。{sys.executable} -m pip/{sys.executable} -m playwright,避免多 Python 环境装歪。scripts/test_md_to_pdf_preflight.py(新增)验证:
nh3缺失时,exit=1,stderr 包含nh3和requirements.txt.github/workflows/ci.ymlquickjob 增加test_md_to_pdf_preflight.pysmokejob 增加 Chromium 预检测试(PLAYWRIGHT_BROWSERS_PATH指向空目录,验证 preflight 捕获并输出chromium)不改的
markdown_to_html.py/render_pdf.pyREADME.md/SKILL.md