@@ -93,15 +93,18 @@ def upload_to_r2(tag, dist = Path("dist")):
93
93
94
94
files_remaining = []
95
95
96
- # upload entire dist directory to r2
96
+ # upload entire dist directory to r2, excluding all_wheels.zip and pyodide_packages.tar.zip
97
97
for root , dirs , files in os .walk (dist ):
98
98
for file in files :
99
+ if file in {"all_wheels.zip" , "pyodide_packages.tar.zip" }:
100
+ continue
99
101
path = Path (root ) / file
100
102
key = tag + "/" + str (path .relative_to (dist ))
101
103
files_remaining .append ((path , key ))
102
104
103
105
# attempt to upload each file 5 times. If after 5 attempts the file is still not accessible at pyodide.edgeworker.net then give up
104
- for i in range (5 ):
106
+ ATTEMPTS = 5
107
+ for i in range (ATTEMPTS ):
105
108
for (path , key ) in files_remaining :
106
109
print (f"uploading { path } to { key } " )
107
110
s3 .upload_file (str (path ), "python-package-bucket" , key )
@@ -134,13 +137,14 @@ def upload_to_r2(tag, dist = Path("dist")):
134
137
print (f"Failed to verify { path } : { e } . Retrying..." )
135
138
new_files_remaining .append ((path , key ))
136
139
137
- if not new_files_remaining :
138
- break
140
+ files_remaining = new_files_remaining
139
141
140
- for ( path , key ) in new_files_remaining :
141
- s3 . delete_object ( Bucket = "python-package-bucket" , Key = key )
142
+ if not files_remaining :
143
+ break
142
144
143
- files_remaining = new_files_remaining
145
+ if i != ATTEMPTS - 1 :
146
+ for (path , key ) in files_remaining :
147
+ s3 .delete_object (Bucket = "python-package-bucket" , Key = key )
144
148
145
149
if files_remaining :
146
150
raise Exception ("Failed to upload packages after 5 attempts: " , files_remaining )
0 commit comments