MCPcopy Create free account
hub / github.com/apache/datafusion / main

Function main

dev/release/download-python-wheels.py:35–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34
35def main():
36 parser = argparse.ArgumentParser(
37 description='Download python binary wheels from release candidate workflow runs.')
38 parser.add_argument('tag', type=str, help='datafusion RC release tag')
39 args = parser.parse_args()
40
41 tag = args.tag
42 ghp_token = os.environ.get("GITHUB_TOKEN")
43 if not ghp_token:
44 print(
45 "ERROR: Personal Github token is required to download workflow artifacts. "
46 "Please specify a token through GITHUB_TOKEN environment variable.")
47 sys.exit(1)
48
49 print(f"Downloading latest python wheels for RC tag {tag}...")
50
51 headers = {
52 "Accept": "application/vnd.github.v3+json",
53 "Authorization": f"token {ghp_token}",
54 }
55 url = f"https://api.github.com/repos/apache/datafusion/actions/runs?branch={tag}"
56 resp = requests.get(url, headers=headers)
57 resp.raise_for_status()
58
59 artifacts_url = None
60 for run in resp.json()["workflow_runs"]:
61 if run["name"] != "Python Release Build":
62 continue
63 artifacts_url = run["artifacts_url"]
64
65 if artifacts_url is None:
66 print("ERROR: Could not find python wheel binaries from Github Action run")
67 sys.exit(1)
68 print(f"Found artifacts url: {artifacts_url}")
69
70 download_url = None
71 artifacts = requests.get(artifacts_url, headers=headers).json()["artifacts"]
72 for artifact in artifacts:
73 if artifact["name"] != "dist":
74 continue
75 download_url = artifact["archive_download_url"]
76
77 if download_url is None:
78 print(f"ERROR: Could not resolve python wheel download URL from list of artifacts: {artifacts}")
79 sys.exit(1)
80 print(f"Extracting archive from: {download_url}...")
81
82 resp = requests.get(download_url, headers=headers, stream=True)
83 resp.raise_for_status()
84 zf = zipfile.ZipFile(io.BytesIO(resp.content))
85 zf.extractall("./")
86
87 for entry in os.listdir("./"):
88 if entry.endswith(".whl") or entry.endswith(".tar.gz"):
89 print(f"Sign and checksum artifact: {entry}")
90 subprocess.check_output([
91 "gpg", "--armor",
92 "--output", entry+".asc",

Callers 1

Calls 6

sha256Method · 0.80
sha512Method · 0.80
readMethod · 0.80
getMethod · 0.45
updateMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…