Skip to content

Commit 93d9295

Browse files
committed
fix: strip trailing data in validate-wheels job after download
The build-time stripping wasn't working reliably on Windows. Move stripping to validate-wheels job which runs on Linux after all wheels are downloaded. This ensures trailing bytes are removed before validation regardless of where they were added.
1 parent 06ba3c7 commit 93d9295

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/release-automated.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,46 @@ jobs:
254254
- name: Install validation tools
255255
run: pip install wheel check-wheel-contents
256256

257+
# Strip trailing data from all wheels before validation
258+
# This handles any trailing bytes added during build or artifact transfer
259+
- name: Strip trailing data from wheels
260+
run: |
261+
python3 << 'EOF'
262+
from pathlib import Path
263+
264+
def strip_trailing_data(wheel_path):
265+
"""Remove trailing bytes after ZIP End of Central Directory."""
266+
with open(wheel_path, 'rb') as f:
267+
data = f.read()
268+
269+
eocd_sig = b'PK\x05\x06'
270+
pos = data.rfind(eocd_sig)
271+
272+
if pos == -1:
273+
print(f" Warning: No EOCD found in {wheel_path.name}")
274+
return False
275+
276+
comment_len = int.from_bytes(data[pos+20:pos+22], 'little')
277+
eocd_end = pos + 22 + comment_len
278+
trailing_bytes = len(data) - eocd_end
279+
280+
if trailing_bytes > 0:
281+
print(f" Stripped {trailing_bytes} trailing bytes from {wheel_path.name}")
282+
with open(wheel_path, 'wb') as f:
283+
f.write(data[:eocd_end])
284+
return True
285+
return False
286+
287+
dist_dir = Path('dist')
288+
wheels = list(dist_dir.glob('*.whl'))
289+
print(f"Checking {len(wheels)} wheel(s) for trailing data...")
290+
fixed = sum(1 for w in sorted(wheels) if strip_trailing_data(w))
291+
if fixed:
292+
print(f"\n✅ Fixed {fixed} wheel(s)")
293+
else:
294+
print("✅ All wheels clean")
295+
EOF
296+
257297
- name: Validate wheel ZIP structure
258298
run: |
259299
python3 << 'EOF'

0 commit comments

Comments
 (0)