Skip to content

Commit 0457f38

Browse files
ratalclaude
andcommitted
fix release: strip License-File from wheel METADATA before uploading to PyPI
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 734c46d commit 0457f38

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/release-linux.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ jobs:
4040
pattern: wheel-linux-*
4141
merge-multiple: true
4242
path: dist/
43+
- name: Strip License-File from wheel metadata
44+
run: |
45+
python - <<'EOF'
46+
import zipfile, os
47+
for whl in os.listdir('dist'):
48+
if not whl.endswith('.whl'): continue
49+
path = os.path.join('dist', whl)
50+
tmp = path + '.tmp'
51+
with zipfile.ZipFile(path, 'r') as zin, zipfile.ZipFile(tmp, 'w', compression=zipfile.ZIP_DEFLATED) as zout:
52+
for item in zin.infolist():
53+
data = zin.read(item.filename)
54+
if item.filename.endswith('/METADATA') or item.filename.endswith('.dist-info/METADATA'):
55+
data = b'\n'.join(l for l in data.split(b'\n') if not l.lower().startswith(b'license-file:'))
56+
zout.writestr(item, data)
57+
os.replace(tmp, path)
58+
EOF
4359
- name: Publish to PyPI
4460
env:
4561
TWINE_USERNAME: __token__

.github/workflows/release-macos.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ jobs:
3030
with:
3131
name: wheel-macos
3232
path: dist/
33+
- name: Strip License-File from wheel metadata
34+
run: |
35+
pip install wheel
36+
python - <<'EOF'
37+
import zipfile, os, re, shutil
38+
for whl in os.listdir('dist'):
39+
if not whl.endswith('.whl'): continue
40+
path = os.path.join('dist', whl)
41+
tmp = path + '.tmp'
42+
with zipfile.ZipFile(path, 'r') as zin, zipfile.ZipFile(tmp, 'w', compression=zipfile.ZIP_DEFLATED) as zout:
43+
for item in zin.infolist():
44+
data = zin.read(item.filename)
45+
if item.filename.endswith('/METADATA') or item.filename.endswith('.dist-info/METADATA'):
46+
data = b'\n'.join(l for l in data.split(b'\n') if not l.lower().startswith(b'license-file:'))
47+
zout.writestr(item, data)
48+
os.replace(tmp, path)
49+
EOF
3350
- name: Publish to PyPI
3451
env:
3552
TWINE_USERNAME: __token__

.github/workflows/release-windows.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ jobs:
2929
with:
3030
name: wheel-windows
3131
path: dist/
32+
- name: Strip License-File from wheel metadata
33+
run: |
34+
python - <<'EOF'
35+
import zipfile, os
36+
for whl in os.listdir('dist'):
37+
if not whl.endswith('.whl'): continue
38+
path = os.path.join('dist', whl)
39+
tmp = path + '.tmp'
40+
with zipfile.ZipFile(path, 'r') as zin, zipfile.ZipFile(tmp, 'w', compression=zipfile.ZIP_DEFLATED) as zout:
41+
for item in zin.infolist():
42+
data = zin.read(item.filename)
43+
if item.filename.endswith('/METADATA') or item.filename.endswith('.dist-info/METADATA'):
44+
data = b'\n'.join(l for l in data.split(b'\n') if not l.lower().startswith(b'license-file:'))
45+
zout.writestr(item, data)
46+
os.replace(tmp, path)
47+
EOF
3248
- name: Publish to PyPI
3349
env:
3450
TWINE_USERNAME: __token__

0 commit comments

Comments
 (0)