@@ -23,48 +23,48 @@ def get_latest_release() -> dict:
2323def download_artifact (url : str , platform_name : str ) -> None :
2424 """Download and extract an artifact to the appropriate platform directory."""
2525 print (f"Downloading artifact for { platform_name } ..." )
26-
26+
2727 # Create platform directory
2828 platform_dir = ARTIFACTS_DIR / platform_name
2929 platform_dir .mkdir (parents = True , exist_ok = True )
30-
30+
3131 # Download the zip file
3232 response = requests .get (url )
3333 response .raise_for_status ()
34-
34+
3535 # Extract the zip file
3636 with zipfile .ZipFile (io .BytesIO (response .content )) as zip_ref :
3737 # Extract all files to the platform directory
3838 zip_ref .extractall (platform_dir )
39-
39+
4040 print (f"Successfully downloaded and extracted artifacts for { platform_name } " )
4141
4242def download_artifacts () -> None :
4343 """Main function to download artifacts. Can be called as a script or from hatch."""
4444 try :
4545 # Create artifacts directory if it doesn't exist
4646 ARTIFACTS_DIR .mkdir (exist_ok = True )
47-
47+
4848 # Get latest release
4949 print ("Fetching latest release information..." )
5050 release = get_latest_release ()
5151 print (f"Found release: { release ['tag_name' ]} " )
52-
52+
5353 # Download each asset
5454 for asset in release ['assets' ]:
5555 # Skip non-zip files
5656 if not asset ['name' ].endswith ('.zip' ):
5757 continue
58-
58+
5959 # Determine platform from asset name
6060 # Example: c2pa-rs-v1.0.0-macosx-arm64.zip
6161 platform_name = asset ['name' ].split ('-' )[- 1 ].replace ('.zip' , '' )
62-
62+
6363 # Download and extract the artifact
6464 download_artifact (asset ['browser_download_url' ], platform_name )
65-
65+
6666 print ("\n All artifacts have been downloaded successfully!" )
67-
67+
6868 except requests .exceptions .RequestException as e :
6969 print (f"Error downloading artifacts: { e } " , file = sys .stderr )
7070 sys .exit (1 )
@@ -77,4 +77,4 @@ def initialize_build() -> None:
7777 download_artifacts ()
7878
7979if __name__ == "__main__" :
80- download_artifacts ()
80+ download_artifacts ()
0 commit comments