Agent Zero AI framework
Bundle compression dev
frdelc38cc1e07695
diff --git a/bundle/bundle.py b/bundle/bundle.pyindex 2975292e7..f58b69fed 100644--- a/bundle/bundle.py+++ b/bundle/bundle.py@@ -7,6 +7,7 @@ from pathlib import Pathimport pathspecimport importlibimport importlib.metadata as metadata+import py7zr # New import for 7z compressiondef get_package_data_folder(package_name):"""Return the package path if it contains data files."""@@ -76,7 +77,31 @@ def cleanup_directories(bundle_name, build_dir, dist_dir, keep_dist=False):if os.path.exists(spec_file):os.remove(spec_file)-def build_executable(script_path, exe_name=None):+def compress_dist_folder(dist_dir, exe_name):+ """Compress the dist folder using py7zr library."""+ try:+ archive_path = Path(dist_dir) / f"{exe_name}.7z"+ files_path = Path(dist_dir) / exe_name+++ # Remove existing archive if it exists+ if archive_path.exists():+ archive_path.unlink()++ print(f"Compressing dist folder to: {archive_path}")++ # Create the 7z archive with maximum compression+ with py7zr.SevenZipFile(archive_path, 'w', filters=[{'id': py7zr.FILTER_LZMA2, 'preset': 9}]) as archive:+ archive.writeall(files_path, arcname=dist_dir.name)++ print("Compression completed successfully")+ return str(archive_path)++ except Exception as e:+ print(f"Error during compression: {e}")+ return None++def build_executable(script_path, exe_name=None, compress=False):"""Run PyInstaller with the correct site-packages path, clean, and additional data."""try:# Resolve the absolute path to the script, relative to the current file location (__file__)@@ -147,6 +172,12 @@ def build_executable(script_path, exe_name=None):print(f"Executable created at: '{dist_dir}/{exe_name}'")print(f"Project files copied to: '{project_files_dir}'")+ # Compress the dist folder if requested+ if compress:+ archive_path = compress_dist_folder(dist_dir, exe_name)+ if archive_path:+ print(f"Created compressed archive at: {archive_path}")+# Final cleanup (keeping dist folder)cleanup_directories(exe_name, build_dir, dist_dir, keep_dist=True)@@ -156,4 +187,4 @@ def build_executable(script_path, exe_name=None):print(f"Error: {e}")if __name__ == "__main__":- build_executable("../run_bundle.py", "agent-zero")+ build_executable("../run_bundle.py", "agent-zero", compress=True)\ No newline at end of filediff --git a/bundle/macos_bundle.sh b/bundle/macos_bundle.shindex e8bad8a1f..3c1432751 100755--- a/bundle/macos_bundle.sh+++ b/bundle/macos_bundle.sh@@ -67,4 +67,28 @@ if [ $? -ne 0 ]; thenexit 1fi+# 9. Move the generated 7z file to the script directory and remove agent-zero folder+BUNDLE_FILE="bundle/dist/agent-zero.7z"+if [ -f "$BUNDLE_FILE" ]; then+ SCRIPT_DIR=$(dirname "$0")+ echo "Moving $BUNDLE_FILE to $SCRIPT_DIR..."+ mv "$BUNDLE_FILE" "$SCRIPT_DIR"+ if [ $? -ne 0 ]; then+ echo "Error moving $BUNDLE_FILE to $SCRIPT_DIR."+ exit 1+ fi+else+ echo "Error: $BUNDLE_FILE not found."+ exit 1+fi++# 10. Remove the agent-zero folder+echo "Deleting agent-zero folder..."+cd ..+rm -rf agent-zero+if [ -d "agent-zero" ]; then+ echo "Error: Failed to delete agent-zero folder."+ exit 1+fi+echo "Script completed."diff --git a/requirements.txt b/requirements.txtindex 8b9c9e6ac..efab97562 100644--- a/requirements.txt+++ b/requirements.txt@@ -19,6 +19,7 @@ markdown==3.7newspaper3k==0.2.8paramiko==3.4.0pathspec==0.12.1+py7zr==0.22.0pyinstaller==6.10.0pypdf==4.3.1python-dotenv==1.0.1