-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump to PyPy 7.3.16 * Bump pip to 24.0 * Script for upload built and signed artifacts * Clean up scripts * Add note about latest pip version
- Loading branch information
1 parent
103c094
commit ba658fa
Showing
5 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""Upload the artifacts to Cloudflare R2 Storage""" | ||
|
||
import os | ||
import boto3 | ||
import re | ||
|
||
BUCKET_NAME = os.getenv("BUCKET_NAME", "pypy-files") | ||
pattern = re.compile(r"\d\.\d(\d)?") | ||
|
||
s3 = boto3.client( | ||
service_name="s3", | ||
endpoint_url='https://8be772befd147a8df540aae0fa15c047.r2.cloudflarestorage.com', | ||
region_name="auto", | ||
) | ||
|
||
CONTENT_TYPE_MAP = { | ||
"sig": "application/pgp-signature", | ||
"bz2": "application/x-bzip2", | ||
"sha256sum": "text/plain" | ||
} | ||
|
||
|
||
def upload_file(file_name: str) -> None: | ||
"""Uploads a file to R2""" | ||
python_version = pattern.search(file_name).group() | ||
try: | ||
s3.upload_file( | ||
f"output/{file_name}", | ||
BUCKET_NAME, | ||
f"pypy/{python_version}/{file_name}", | ||
ExtraArgs={ | ||
"ContentType": CONTENT_TYPE_MAP.get(file_name.split('.')[-1], 'application/octet-stream'), | ||
"CacheControl": "public, max-age=31536000", | ||
"ContentDisposition": f"attachment; filename={file_name.split('/')[-1]}", | ||
} | ||
) | ||
except Exception as e: | ||
print(f"Failed to upload {file_name} to {file_name}: {e}") | ||
raise e | ||
print(f"Uploaded {file_name}") | ||
|
||
|
||
if __name__ == "__main__": | ||
if not os.path.exists("output"): | ||
print("No output directory found. Assuming no files to upload. Exiting.") | ||
exit(0) | ||
for file in os.listdir("output"): | ||
upload_file(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters