【Hackathon 10th Spring No.46】Add Windows build system support (Part 2/3)#7502
Conversation
|
Thanks for your contribution! |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-20 13:54 CST
📋 Review 摘要
PR 概述:新增 Windows 构建脚本 build.bat,并为 setup_ops.py 添加 Windows 平台链接器配置
变更范围:build.bat(新增)、custom_ops/setup_ops.py
影响面 Tag:OP CI
📝 PR 规范检查
PR 标题缺少官方 Tag,且描述与实际变更不一致(描述称"仅添加注释",但实际新增了 build.bat 文件并修改了 setup_ops.py 的链接逻辑)。
标题建议(可直接复制):
[Feature] Add Windows build script (build.bat) and platform-specific linker config (Part 2/3)
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🔴 Bug | build.bat:62 |
setup_ops.py install 缺少 --install-lib 及 copy_ops 步骤,wheel 不包含 custom ops |
| 🟡 建议 | build.bat:18 |
注释写 "Python 3.10+" 但代码检查的是 >= 3.9 |
| 🟡 建议 | build.bat:80 |
缺少 init/version_info/cleanup 等构建步骤 |
总体评价
setup_ops.py 的平台适配逻辑正确,Windows MSVC 链接器 flag 符合规范。但 build.bat 存在关键流程缺失——custom ops 编译产物未拷贝至 fastdeploy 源码目录,导致最终打包的 wheel 不包含 ops,使用该脚本构建的产物功能不完整。建议参考 build.sh 的 build_and_install_ops + copy_ops 流程补全。
|
|
||
| REM FastDeploy Windows build script | ||
| REM Mirrors build.sh for Windows environments. | ||
| REM Requires: Visual Studio Build Tools, CUDA Toolkit, Python 3.10+ |
There was a problem hiding this comment.
🟡 建议 注释写的是 Python 3.10+,但下方第 36-43 行的版本检查逻辑实际要求的是 >= 3.9,与 build.sh 一致。
建议保持一致:
REM Requires: Visual Studio Build Tools, CUDA Toolkit, Python 3.9+| if !ERRORLEVEL! neq 0 ( | ||
| echo [FAIL] Custom ops build failed. | ||
| popd | ||
| exit /b 1 |
There was a problem hiding this comment.
🔴 Bug 此处直接调用 setup_ops.py install 没有指定 --install-lib 参数,编译产物会安装到 Python 的 site-packages 而不是临时目录。
对比 build.sh 的流程:
setup_ops.py install --install-lib ${tmp_dir}→ 安装到临时目录copy_ops→ 将产物拷贝到fastdeploy/model_executor/ops/gpusetup.py bdist_wheel→ 打包 wheel(包含 ops)
当前 build.bat 缺少这两个关键步骤,导致后续 setup.py bdist_wheel 打出的 wheel 不会包含编译好的 custom ops,最终 wheel 功能不完整。
建议参考 build.sh 的 build_and_install_ops + copy_ops 逻辑补全:
pushd custom_ops
set OPS_TMP_DIR=tmp
%PYTHON% setup_ops.py install --install-lib %OPS_TMP_DIR%
REM ... copy ops to fastdeploy\model_executor\ops\gpu
popd| if !ERRORLEVEL! neq 0 ( | ||
| echo [FAIL] Wheel build failed. | ||
| exit /b 1 | ||
| ) |
There was a problem hiding this comment.
🟡 建议 对比 build.sh,当前 build.bat 缺少以下构建步骤,可能导致构建流程不完整:
- init:清理旧构建目录(
build/、*.egg-info)、安装setuptools_scm - version_info:写入
fastdeploy/version.txt(包含 git commit、Paddle 版本、CUDA 版本等) - cleanup:构建完成后清理中间文件
如果这些步骤计划在 Part 3 中补充,建议在此处添加 REM TODO(Part 3) 注释说明。
Motivation
Document Windows build-system notes and add minimal clarifying comments to
build.batandsetup_ops.py.Modifications
build.batandcustom_ops/setup_ops.pyto clarify Windows-specific steps. No functional changes.Checklist