| 2 | import os |
| 3 | |
| 4 | def create_extension_zip(source_dir, output_filename): |
| 5 | with zipfile.ZipFile(output_filename, 'w', zipfile.ZIP_DEFLATED) as zipf: |
| 6 | for root, dirs, files in os.walk(source_dir): |
| 7 | # Exclude hidden directories |
| 8 | dirs[:] = [d for d in dirs if d not in ['.git', '__pycache__', '.idea', '.vscode']] |
| 9 | |
| 10 | for file in files: |
| 11 | # Exclude build artifacts and system files |
| 12 | if file.endswith(('.zip', '.DS_Store')): |
| 13 | continue |
| 14 | |
| 15 | file_path = os.path.join(root, file) |
| 16 | arcname = os.path.relpath(file_path, source_dir) |
| 17 | arcname = arcname.replace(os.path.sep, '/') |
| 18 | zipf.write(file_path, arcname) |
| 19 | print(f"Successfully created {output_filename}") |
| 20 | |
| 21 | # Paths |
| 22 | base_dir = os.path.dirname(os.path.abspath(__file__)) |