Skip to content

Commit 16cf550

Browse files
Add logic for downloading platform-specific tarball
1 parent 3fa1425 commit 16cf550

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

PCbuild/get_external.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import argparse
44
import os
55
import pathlib
6+
import platform
67
import sys
78
import tarfile
89
import time
@@ -44,13 +45,24 @@ def fetch_zip(commit_hash, zip_dir, *, org='python', binary=False, verbose):
4445

4546

4647
def fetch_release(tag, tarball_dir, *, org='python', verbose=False):
47-
url = f'https://github.com/{org}/cpython-bin-deps/releases/download/{tag}/{tag}.tar.xz'
48-
reporthook = None
49-
if verbose:
50-
reporthook = print
48+
arch = platform.machine()
49+
reporthook = print if verbose else None
5150
tarball_dir.mkdir(parents=True, exist_ok=True)
52-
output_path = tarball_dir / f'{tag}.tar.xz'
53-
retrieve_with_retries(url, output_path, reporthook)
51+
52+
arch_filename = f'{tag}-{arch}.tar.xz'
53+
arch_url = f'https://github.com/{org}/cpython-bin-deps/releases/download/{tag}/{arch_filename}'
54+
try:
55+
output_path = tarball_dir / arch_filename
56+
retrieve_with_retries(arch_url, output_path, reporthook)
57+
return output_path
58+
except OSError:
59+
if verbose:
60+
print(f'{arch_filename} not found, trying generic build...')
61+
62+
generic_filename = f'{tag}.tar.xz'
63+
generic_url = f'https://github.com/{org}/cpython-bin-deps/releases/download/{tag}/{generic_filename}'
64+
output_path = tarball_dir / generic_filename
65+
retrieve_with_retries(generic_url, output_path, reporthook)
5466
return output_path
5567

5668

0 commit comments

Comments
 (0)