#!/usr/bin/env python3 """Create an AYON addon .zip package for distribution.""" import os import sys import zipfile from pathlib import Path def create_package(): root = Path(__file__).parent # Read version version_file = root / "server" / "ayon_matrix_publish" / "version.py" version = "0.1.0" if version_file.exists(): exec(version_file.read_text(), {}, {}) version = locals().get("__version__", version) package_name = f"matrix_publish-{version}.zip" package_path = root / package_name print(f"Creating {package_name}...") with zipfile.ZipFile(package_path, "w", zipfile.ZIP_DEFLATED) as zf: # Add package.py zf.write(root / "package.py", "package.py") # Add server files server_dir = root / "server" for file_path in server_dir.rglob("*"): if file_path.is_file() and "__pycache__" not in str(file_path): arcname = str(file_path.relative_to(root)) zf.write(file_path, arcname) print(f" + {arcname}") # Add client files client_dir = root / "client" if client_dir.exists(): for file_path in client_dir.rglob("*"): if file_path.is_file() and "__pycache__" not in str(file_path): arcname = str(file_path.relative_to(root)) zf.write(file_path, arcname) print(f" + {arcname}") print(f"\nPackage created: {package_path}") print(f"Size: {package_path.stat().st_size / 1024:.1f} KB") if __name__ == "__main__": create_package()