1
0

make_delivery_zip.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import os
  2. import zipfile
  3. def create_delivery_zip():
  4. zip_name = "LocalFoodAI_lanfr144_Delivery_make_delivery.zip"
  5. exclude_dirs = {".git", ".venv", "__pycache__", "node_modules", ".vscode", ".agents", "backups", "logs"}
  6. exclude_files = {
  7. "LocalFoodAI_lanfr144_Delivery.zip",
  8. "Copie de secours de description.wbk",
  9. "~$scription.docx",
  10. }
  11. print(f"Creating clean delivery archive: {zip_name}...")
  12. with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED, allowZip64=True ) as zipf:
  13. for root, dirs, files in os.walk('.'):
  14. # Modify dirs in-place to exclude specified directories recursively
  15. dirs[:] = [d for d in dirs if d not in exclude_dirs]
  16. for file in files:
  17. if file in exclude_files:
  18. continue
  19. # Exclude lock files or temp files starting with ~$
  20. if file.startswith("~$") or file.endswith(".pyc") or file.endswith(".wbk"):
  21. continue
  22. # Exclude large raw CSV datasets (they will be synced automatically during setup)
  23. filepath = os.path.join(root, file)
  24. if file.endswith(".csv") or os.path.getsize(filepath) > 10 * 1024 * 1024: # Exclude files > 10MB
  25. print(f"Skipping large file: {filepath} ({os.path.getsize(filepath) / (1024*1024):.2f} MB)")
  26. continue
  27. relative_path = os.path.relpath(filepath, '.')
  28. zipf.write(relative_path)
  29. print(f"Archive successfully created at {os.path.abspath(zip_name)}")
  30. if __name__ == "__main__":
  31. create_delivery_zip()