Skip to content

Commit d0eec68

Browse files
committed
ci: assert built wheel name matches cache key after source build
Add a sanity check that runs after `python setup.py bdist_wheel` and compares the built wheel basename against the cache URL we'd reconstruct on the next run. If they diverge — e.g. someone changes the torch_wheel_name template, or PyTorch's setup.py renames its wheels — fail loudly with a pointer to the function that needs fixing, rather than silently miss the cache forever. Catches the same class of regression that produced the original "+gitrelease" bug fixed in the parent commit (PR #19350), on the very next CI run that hits the source-build path. Authored with Claude Code.
1 parent 319b9e6 commit d0eec68

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

.ci/scripts/utils.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,30 @@ install_pytorch_and_domains() {
131131
USE_DISTRIBUTED=1 python setup.py bdist_wheel
132132
pip install "$(echo dist/*.whl)"
133133

134+
# Invariant: the basename setup.py just produced must match the cache
135+
# URL we'd reconstruct on the next run. If they diverge (someone edits
136+
# torch_wheel_name above, or PyTorch renames its wheels), the cache
137+
# will silently miss and every macOS run will fall back to a ~30-min
138+
# source build. Fail loudly so the regression is caught immediately.
139+
shopt -s nullglob
140+
local built_wheels=(dist/*.whl)
141+
shopt -u nullglob
142+
if [[ ${#built_wheels[@]} -ne 1 ]]; then
143+
echo "ERROR: expected exactly 1 wheel in dist/, found ${#built_wheels[@]}" >&2
144+
exit 1
145+
fi
146+
local built_wheel_name
147+
built_wheel_name=$(basename "${built_wheels[0]}")
148+
local expected_wheel_name="${torch_wheel_name//\%2B/+}"
149+
if [[ "${built_wheel_name}" != "${expected_wheel_name}" ]]; then
150+
echo "ERROR: built torch wheel name does not match cache URL key:" >&2
151+
echo " built: ${built_wheel_name}" >&2
152+
echo " expected: ${expected_wheel_name}" >&2
153+
echo "Fix torch_wheel_name construction in install_pytorch_and_domains" >&2
154+
echo "in .ci/scripts/utils.sh" >&2
155+
exit 1
156+
fi
157+
134158
# Only AWS runners have access to S3
135159
if command -v aws && [[ -z "${GITHUB_RUNNER:-}" ]]; then
136160
for wheel_path in dist/*.whl; do

0 commit comments

Comments
 (0)