Switch to .xz by default for SDK downloads (#1281)
This is a bit of a hack but I can't think of another way to do it. Basically when downloading SDKs, we first try the new `.xz` extension. If that fails, we fall back to the old `.tbz2`. Both these first two download attempts we run in "silent" mode. If both of them fail we re-run the original request in non-silent mode so that the error message will always contain the original `.xz` extension. See #1235
This commit is contained in:
58
emsdk.py
58
emsdk.py
@@ -672,7 +672,8 @@ def get_download_target(url, dstpath, filename_prefix=''):
|
|||||||
|
|
||||||
# On success, returns the filename on the disk pointing to the destination file that was produced
|
# On success, returns the filename on the disk pointing to the destination file that was produced
|
||||||
# On failure, returns None.
|
# On failure, returns None.
|
||||||
def download_file(url, dstpath, download_even_if_exists=False, filename_prefix=''):
|
def download_file(url, dstpath, download_even_if_exists=False,
|
||||||
|
filename_prefix='', silent=False):
|
||||||
debug_print('download_file(url=' + url + ', dstpath=' + dstpath + ')')
|
debug_print('download_file(url=' + url + ', dstpath=' + dstpath + ')')
|
||||||
file_name = get_download_target(url, dstpath, filename_prefix)
|
file_name = get_download_target(url, dstpath, filename_prefix)
|
||||||
|
|
||||||
@@ -717,9 +718,10 @@ def download_file(url, dstpath, download_even_if_exists=False, filename_prefix='
|
|||||||
print(']')
|
print(']')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errlog("Error: Downloading URL '" + url + "': " + str(e))
|
if not silent:
|
||||||
if "SSL: CERTIFICATE_VERIFY_FAILED" in str(e) or "urlopen error unknown url type: https" in str(e):
|
errlog("Error: Downloading URL '" + url + "': " + str(e))
|
||||||
errlog("Warning: Possibly SSL/TLS issue. Update or install Python SSL root certificates (2048-bit or greater) supplied in Python folder or https://pypi.org/project/certifi/ and try again.")
|
if "SSL: CERTIFICATE_VERIFY_FAILED" in str(e) or "urlopen error unknown url type: https" in str(e):
|
||||||
|
errlog("Warning: Possibly SSL/TLS issue. Update or install Python SSL root certificates (2048-bit or greater) supplied in Python folder or https://pypi.org/project/certifi/ and try again.")
|
||||||
rmfile(file_name)
|
rmfile(file_name)
|
||||||
return None
|
return None
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@@ -1407,18 +1409,36 @@ def download_and_extract(archive, dest_dir, filename_prefix='', clobber=True):
|
|||||||
debug_print('download_and_extract(archive=' + archive + ', dest_dir=' + dest_dir + ')')
|
debug_print('download_and_extract(archive=' + archive + ', dest_dir=' + dest_dir + ')')
|
||||||
|
|
||||||
url = urljoin(emsdk_packages_url, archive)
|
url = urljoin(emsdk_packages_url, archive)
|
||||||
download_target = get_download_target(url, download_dir, filename_prefix)
|
|
||||||
|
|
||||||
received_download_target = download_file(url, download_dir, not KEEP_DOWNLOADS, filename_prefix)
|
def try_download(url, silent=False):
|
||||||
if not received_download_target:
|
return download_file(url, download_dir, not KEEP_DOWNLOADS,
|
||||||
|
filename_prefix, silent=silent)
|
||||||
|
|
||||||
|
# Special hack for the wasm-binaries we transitioned from `.bzip2` to
|
||||||
|
# `.xz`, but we can't tell from the version/url which one to use, so
|
||||||
|
# try one and then fall back to the other.
|
||||||
|
success = False
|
||||||
|
if 'wasm-binaries' in archive and os.path.splitext(archive)[1] == '.xz':
|
||||||
|
success = try_download(url, silent=True)
|
||||||
|
if not success:
|
||||||
|
alt_url = url.replace('.tar.xz', '.tbz2')
|
||||||
|
success = try_download(alt_url, silent=True)
|
||||||
|
if success:
|
||||||
|
url = alt_url
|
||||||
|
|
||||||
|
if not success:
|
||||||
|
success = try_download(url)
|
||||||
|
|
||||||
|
if not success:
|
||||||
return False
|
return False
|
||||||
assert received_download_target == download_target
|
|
||||||
|
|
||||||
# Remove the old directory, since we have some SDKs that install into the
|
# Remove the old directory, since we have some SDKs that install into the
|
||||||
# same directory. If we didn't do this contents of the previous install
|
# same directory. If we didn't do this contents of the previous install
|
||||||
# could remain.
|
# could remain.
|
||||||
if clobber:
|
if clobber:
|
||||||
remove_tree(dest_dir)
|
remove_tree(dest_dir)
|
||||||
|
|
||||||
|
download_target = get_download_target(url, download_dir, filename_prefix)
|
||||||
if archive.endswith('.zip'):
|
if archive.endswith('.zip'):
|
||||||
return unzip(download_target, dest_dir)
|
return unzip(download_target, dest_dir)
|
||||||
else:
|
else:
|
||||||
@@ -2071,17 +2091,29 @@ def get_emscripten_releases_tot():
|
|||||||
arch = ''
|
arch = ''
|
||||||
if ARCH == 'arm64':
|
if ARCH == 'arm64':
|
||||||
arch = '-arm64'
|
arch = '-arm64'
|
||||||
for release in recent_releases:
|
|
||||||
url = emscripten_releases_download_url_template % (
|
def make_url(ext):
|
||||||
|
return emscripten_releases_download_url_template % (
|
||||||
os_name(),
|
os_name(),
|
||||||
release,
|
release,
|
||||||
arch,
|
arch,
|
||||||
'tbz2' if not WINDOWS else 'zip'
|
ext,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for release in recent_releases:
|
||||||
|
make_url('tbz2' if not WINDOWS else 'zip')
|
||||||
try:
|
try:
|
||||||
urlopen(url)
|
urlopen(make_url('tar.xz' if not WINDOWS else 'zip'))
|
||||||
except:
|
except:
|
||||||
continue
|
if not WINDOWS:
|
||||||
|
# Try the old `.tbz2` name
|
||||||
|
# TODO:remove this once tot builds are all using xz
|
||||||
|
try:
|
||||||
|
urlopen(make_url('tbz2'))
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
continue
|
||||||
return release
|
return release
|
||||||
exit_with_error('failed to find build of any recent emsdk revision')
|
exit_with_error('failed to find build of any recent emsdk revision')
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@
|
|||||||
"version": "%releases-tag%",
|
"version": "%releases-tag%",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"arch": "x86_64",
|
"arch": "x86_64",
|
||||||
"linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries.tbz2",
|
"linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries.tar.xz",
|
||||||
"macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries.tbz2",
|
"macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries.tar.xz",
|
||||||
"windows_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/%releases-tag%/wasm-binaries.zip",
|
"windows_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/%releases-tag%/wasm-binaries.zip",
|
||||||
"download_prefix": "%releases-tag%-",
|
"download_prefix": "%releases-tag%-",
|
||||||
"install_path": "upstream",
|
"install_path": "upstream",
|
||||||
@@ -48,8 +48,8 @@
|
|||||||
"version": "%releases-tag%",
|
"version": "%releases-tag%",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"arch": "arm64",
|
"arch": "arm64",
|
||||||
"macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries-arm64.tbz2",
|
"macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries-arm64.tar.xz",
|
||||||
"linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries-arm64.tbz2",
|
"linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries-arm64.tar.xz",
|
||||||
"download_prefix": "%releases-tag%-",
|
"download_prefix": "%releases-tag%-",
|
||||||
"install_path": "upstream",
|
"install_path": "upstream",
|
||||||
"activated_path": "%installation_dir%/emscripten",
|
"activated_path": "%installation_dir%/emscripten",
|
||||||
|
|||||||
Reference in New Issue
Block a user