This repository has been archived by the owner on Feb 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e724031
commit a4ab45e
Showing
8 changed files
with
216 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,3 +171,6 @@ cython_debug/ | |
|
||
# Rattler | ||
output | ||
|
||
# Mojo | ||
**/*.mojopkg |
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,40 @@ | ||
import sys | ||
from pathlib import Path | ||
import hashlib | ||
import os | ||
import requests | ||
|
||
channel = "https://prefix.dev/api/v1/upload/mojo-community" | ||
token = os.environ.get("PREFIX_API_KEY") | ||
if not token: | ||
print("Please set PREFIX_API_KEY to your Prefix API key.") | ||
sys.exit(1) | ||
|
||
def upload(fn): | ||
data = fn.read_bytes() | ||
|
||
# skip if larger than 100Mb | ||
if len(data) > 100 * 1024 * 1024: | ||
print("Skipping", fn, "because it is too large") | ||
return | ||
|
||
name = fn.name | ||
sha256 = hashlib.sha256(data).hexdigest() | ||
headers = { | ||
"X-File-Name": name, | ||
"X-File-SHA256": sha256, | ||
"Authorization": f"Bearer {token}", | ||
"Content-Length": str(len(data) + 1), | ||
"Content-Type": "application/octet-stream", | ||
} | ||
|
||
r = requests.post(channel, data=data, headers=headers) | ||
print(f"Uploaded package {name} with status {r.status_code}") | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) > 1: | ||
upload(Path(sys.argv[1])) | ||
else: | ||
print("Usage: upload.py <package>") | ||
sys.exit(1) |
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
Oops, something went wrong.