@@ -87,6 +87,30 @@ def copy_config_to_dist():
8787 if not copied :
8888 print ("Warning: No config file found to copy." )
8989
90+ def create_zip (debug_mode ):
91+ """Packages the dist folder into a zip file."""
92+ source_dir = os .path .join (OUTPUT_DIR , EXECUTABLE_NAME )
93+
94+ zip_name = EXECUTABLE_NAME
95+ if debug_mode :
96+ zip_name += "-debug"
97+
98+ # shutil.make_archive expects the base_name without extension
99+ # It creates base_name.zip
100+
101+ print (f"\n Packaging into { zip_name } .zip..." )
102+
103+ # format='zip': create a zip file
104+ # root_dir=OUTPUT_DIR: the root directory to archive
105+ # base_dir=EXECUTABLE_NAME: the directory inside root_dir to start archiving from
106+ # This prevents the zip from containing 'dist/...' structure, but rather just the executable folder
107+
108+ # We want the zip to contain the top-level folder 'RainingKeysPython'
109+ # So we archive 'dist' but only the 'RainingKeysPython' subdirectory
110+
111+ shutil .make_archive (zip_name , 'zip' , root_dir = OUTPUT_DIR , base_dir = EXECUTABLE_NAME )
112+ print (f"Zip created: { zip_name } .zip" )
113+
90114def main ():
91115 # 1. Clean previous builds
92116 clean_directories ()
@@ -107,8 +131,12 @@ def main():
107131 # 4. Copy config
108132 copy_config_to_dist ()
109133
110- print ("\n Build complete!" )
111- print (f"Output: { os .path .join (OUTPUT_DIR , EXECUTABLE_NAME )} " )
134+ # 5. Zip
135+ create_zip (debug_mode )
136+
137+ print ("\n Build and packaging complete!" )
138+ print (f"Output folder: { os .path .join (OUTPUT_DIR , EXECUTABLE_NAME )} " )
139+ print (f"Zip file: { EXECUTABLE_NAME + ('-debug' if debug_mode else '' )} .zip" )
112140
113141if __name__ == "__main__" :
114142 main ()
0 commit comments