fix(release): recognize the installed wheel in deep doctor - #5024
Conversation
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
huangruiteng
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
PR #5024,精确 head 38b47b326cd6e3db1d416d96080004aaab503bda。
动机
v1.2.0 的真实 wheel 安装检查暴露了一个确定性误判:从独立虚拟环境运行深度 doctor,旧版却报告机器上另一个全局 loopx,并把已安装 wheel 当作源码快照,寻找 wheel 本不包含的源码脚本,最终退出码为 1。这会阻断发布,也让安装用户得到错误诊断。本 PR 修好这个独立的安装门槛;整版发布仍需在合并后的最终提交重新验收。
改动思路
保留已有两种合法安装形态:wheel 走 Python distribution 的 RECORD 检查,源码 checkout 走源码快照检查。collect_installation_doctor() 现在优先使用当前运行的 console script,再把已有分发探测器确实拥有的 doctor.py 交给它;探测与深度检查本身没有复制或放宽。只修其中一个输入仍会留下另一处错误,跳过 doctor 更会失去安装用户的关键验收,因此采用两个直接替换。
具体改动
loopx/release_candidate.py 把命令选择从 PATH 优先改为当前调用优先,并把 RECORD 所有权查询的模块从 release_candidate.py 改成 doctor.py。后者与既有 python_distribution_install() 的所有权规则一致,能让 collect_deep_install_checks() 选择正确的 wheel 检查。tests/test_doctor_installation_scope.py 加入一个针对性回归:同时提供当前环境与旧环境命令路径,检查选择的是当前命令以及正确的模块和分发根。没有新增状态、CLI 选项或持久化格式。
关键代码讲解
collect_installation_doctor()仍是诊断入口和唯一分流处;在 wheel 中将当前运行脚本及 RECORD 根交给已有深度检查器,在源码 checkout 中保留原有 fallback。test_installation_scope_uses_current_distribution_and_console_script()用两个不同命令路径固定优先级,并断言传给已有探测器的是实际拥有分发记录的模块。测试只能检验选择逻辑;真实 wheel 安装重放另行验证了打包边界。
对主干的风险
主要风险是修复测试通过但实际 wheel 仍缺文件,或源码开发模式被误分流。对此用两个基线与 head 的独立 wheel 从 checkout 外执行相同命令:旧版退出 1、选源码检查及全局命令,新版退出 0、选 distribution 检查及本环境命令;新版完整深度 doctor 与源码 checkout 深度 doctor 也通过。28 项定向测试、Ruff、mypy、两文件公开边界扫描、有效质量回执和风险预合并检查均通过。Goal 配置不等待 PR CI,因此本次不查询 PR CI。没有权限、持久状态和 Goal 调度变化,实际 release 产物仍须在最终 main 重建验证。
我的整体评价
这是必要且比例合适的修复:生产代码只更正两个已有 helper 的输入,没有引入第二套安装判断。长期发布流程恢复可用,安装用户得到与实际运行环境一致的结果;源码路径仍可用。精确 head 的正反路径和真实包安装证据支持 APPROVE。合并之后不会沿用本 PR 的旧提交验收,而会对最终 main 重跑完整发布准入。用户已明确授权本批修复的 admin bypass,合并仍以精确 head readiness 为准。
English verdict: APPROVE - exact head 38b47b3; baseline wheel fails, fixed wheel and source checkout pass, with focused/static/boundary/quality/risk checks completed; final release qualification remains separate.
Problem and result
A clean installed v1.2.0 wheel failed
loopx doctor --deep --installation-onlyoutside a source checkout. The release doctor suppliedrelease_candidate.pyto a RECORD ownership check that matchesdoctor.py, so it treated the installed distribution as unavailable and ran source-snapshot checks. It also preferred an unrelatedloopxonPATHover the console script that actually invoked the current virtual environment.The doctor now resolves the distribution from the owned
doctor.pymodule and prefers its current console-script invocation. The source-snapshot branch remains available when no installed distribution owns the command.Validation
This repairs an installed-user release gate. The final merged release commit will be rebuilt and requalified before tagging.