import os, zipfile, sys SRC = os.path.expanduser('~/.workbuddy/skills/bun-report-parser') OUT = r'E:/cfc/docs/参考资料/publish/bun-report-parser-skill-v1.1.2.zip' files = [] for root, dirs, fs in os.walk(SRC): dirs[:] = [d for d in dirs if d != '__pycache__'] for f in fs: if f.endswith('.pyc') or '.bak' in f: continue full = os.path.join(root, f) rel = os.path.relpath(full, os.path.dirname(SRC)) files.append((full, rel.replace(os.sep, '/'))) with zipfile.ZipFile(OUT, 'w', zipfile.ZIP_DEFLATED) as zf: for full, rel in files: zf.write(full, rel) print('packaged', len(files), 'files ->', OUT) with zipfile.ZipFile(OUT) as zf: for n in zf.namelist(): print(' ', n) bad = [n for n in zf.namelist() if '.bak' in n or n.endswith('.pyc') or '__pycache__' in n] print('DIRTY:', bad) if bad else print('CLEAN') print('size KB:', round(os.path.getsize(OUT) / 1024, 1))