From 4f2db9682c78d2c033f8fc079d1da880dcd1f8be Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 10 Jul 2023 14:04:24 -0700 Subject: [PATCH] Rename `zipfile` to `archive` or `download` as appropriate. NFC (#1257) --- .flake8 | 2 +- .gitignore | 2 +- emsdk.py | 23 ++++++++++++----------- emsdk_manifest.json | 10 +++++----- test/test.py | 2 +- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.flake8 b/.flake8 index b67d9c2..4a0ec27 100644 --- a/.flake8 +++ b/.flake8 @@ -19,5 +19,5 @@ exclude = ./node ./python ./temp - ./zips + ./downloads ./crunch diff --git a/.gitignore b/.gitignore index 0d794d2..d181c30 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,7 @@ __pycache__ /node /python /temp -/zips +/downloads /crunch /java /mingw diff --git a/emsdk.py b/emsdk.py index 28dc2ed..52f2f68 100644 --- a/emsdk.py +++ b/emsdk.py @@ -49,7 +49,7 @@ emscripten_releases_download_url_template = "https://storage.googleapis.com/weba # `main.zip` perhaps. emsdk_zip_download_url = 'https://github.com/emscripten-core/emsdk/archive/HEAD.zip' -zips_subdir = 'zips/' +download_dir = 'downloads/' extra_release_tag = None @@ -1403,13 +1403,13 @@ def build_binaryen_tool(tool): return success -def download_and_unzip(zipfile, dest_dir, filename_prefix='', clobber=True): - debug_print('download_and_unzip(zipfile=' + zipfile + ', dest_dir=' + dest_dir + ')') +def download_and_extract(archive, dest_dir, filename_prefix='', clobber=True): + debug_print('download_and_extract(archive=' + archive + ', dest_dir=' + dest_dir + ')') - url = urljoin(emsdk_packages_url, zipfile) - download_target = get_download_target(url, zips_subdir, filename_prefix) + url = urljoin(emsdk_packages_url, archive) + download_target = get_download_target(url, download_dir, filename_prefix) - received_download_target = download_file(url, zips_subdir, not KEEP_DOWNLOADS, filename_prefix) + received_download_target = download_file(url, download_dir, not KEEP_DOWNLOADS, filename_prefix) if not received_download_target: return False assert received_download_target == download_target @@ -1419,7 +1419,7 @@ def download_and_unzip(zipfile, dest_dir, filename_prefix='', clobber=True): # could remain. if clobber: remove_tree(dest_dir) - if zipfile.endswith('.zip'): + if archive.endswith('.zip'): return unzip(download_target, dest_dir) else: return untargz(download_target, dest_dir) @@ -1874,7 +1874,8 @@ class Tool(object): elif hasattr(self, 'git_branch'): success = git_clone_checkout_and_pull(url, self.installation_path(), self.git_branch) elif url.endswith(ARCHIVE_SUFFIXES): - success = download_and_unzip(url, self.installation_path(), filename_prefix=getattr(self, 'zipfile_prefix', '')) + success = download_and_extract(url, self.installation_path(), + filename_prefix=getattr(self, 'download_prefix', '')) else: assert False, 'unhandled url type: ' + url @@ -1924,8 +1925,8 @@ class Tool(object): return url = self.download_url() if url.endswith(ARCHIVE_SUFFIXES): - download_target = get_download_target(url, zips_subdir, getattr(self, 'zipfile_prefix', '')) - debug_print("Deleting temporary zip file " + download_target) + download_target = get_download_target(url, download_dir, getattr(self, 'download_prefix', '')) + debug_print("Deleting temporary download: " + download_target) rmfile(download_target) def uninstall(self): @@ -2110,7 +2111,7 @@ def update_emsdk(): if is_emsdk_sourced_from_github(): errlog('You seem to have bootstrapped Emscripten SDK by cloning from GitHub. In this case, use "git pull" instead of "emsdk update" to update emsdk. (Not doing that automatically in case you have local changes)') sys.exit(1) - if not download_and_unzip(emsdk_zip_download_url, EMSDK_PATH, clobber=False): + if not download_and_extract(emsdk_zip_download_url, EMSDK_PATH, clobber=False): sys.exit(1) diff --git a/emsdk_manifest.json b/emsdk_manifest.json index f7f3a2b..1fb2ca2 100644 --- a/emsdk_manifest.json +++ b/emsdk_manifest.json @@ -37,7 +37,7 @@ "linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries.tbz2", "macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries.tbz2", "windows_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/%releases-tag%/wasm-binaries.zip", - "zipfile_prefix": "%releases-tag%-", + "download_prefix": "%releases-tag%-", "install_path": "upstream", "activated_path": "%installation_dir%/emscripten", "activated_cfg": "LLVM_ROOT='%installation_dir%/bin';BINARYEN_ROOT='%installation_dir%';EMSCRIPTEN_ROOT='%installation_dir%/emscripten'", @@ -50,7 +50,7 @@ "arch": "arm64", "macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries-arm64.tbz2", "linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries-arm64.tbz2", - "zipfile_prefix": "%releases-tag%-", + "download_prefix": "%releases-tag%-", "install_path": "upstream", "activated_path": "%installation_dir%/emscripten", "activated_cfg": "LLVM_ROOT='%installation_dir%/bin';BINARYEN_ROOT='%installation_dir%';EMSCRIPTEN_ROOT='%installation_dir%/emscripten'", @@ -478,7 +478,7 @@ "append_bitness": false, "windows_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.zip", "unix_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.tar.gz", - "zipfile_prefix": "emscripten-e", + "download_prefix": "emscripten-e", "activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%';EMSCRIPTEN_NATIVE_OPTIMIZER='%installation_dir%%generator_prefix%_32bit_optimizer/%cmake_build_type_on_win%optimizer%.exe%'", "activated_path": "%installation_dir%", "activated_env": "EMSCRIPTEN=%installation_dir%;EMSCRIPTEN_NATIVE_OPTIMIZER=%installation_dir%%generator_prefix%_32bit_optimizer/%cmake_build_type_on_win%optimizer%.exe%", @@ -518,7 +518,7 @@ "append_bitness": false, "windows_url": "https://github.com/WebAssembly/binaryen/archive/%binaryen_tag%.zip", "unix_url": "https://github.com/WebAssembly/binaryen/archive/%binaryen_tag%.tar.gz", - "zipfile_prefix": "binaryen-e", + "download_prefix": "binaryen-e", "activated_cfg": "BINARYEN_ROOT='%installation_dir%%generator_prefix%_64bit_binaryen'", "activated_path": "%installation_dir%%generator_prefix%_64bit_binaryen/bin", "activated_env": "BINARYEN_ROOT=%installation_dir%%generator_prefix%_64bit_binaryen", @@ -534,7 +534,7 @@ "append_bitness": false, "windows_url": "https://github.com/WebAssembly/binaryen/archive/%binaryen_tag%.zip", "unix_url": "https://github.com/WebAssembly/binaryen/archive/%binaryen_tag%.tar.gz", - "zipfile_prefix": "binaryen-e", + "download_prefix": "binaryen-e", "activated_cfg": "BINARYEN_ROOT='%installation_dir%%generator_prefix%_64bit_binaryen'", "activated_path": "%installation_dir%%generator_prefix%_64bit_binaryen/bin", "activated_env": "BINARYEN_ROOT=%installation_dir%%generator_prefix%_64bit_binaryen", diff --git a/test/test.py b/test/test.py index 32cbad2..1b1233c 100755 --- a/test/test.py +++ b/test/test.py @@ -269,7 +269,7 @@ int main() { # With EMSDK_KEEP_DOWNLOADS the downloading should happen on the first # install of 2.0.28, and again when we install 2.0.29, but not on the # second install of 2.0.28 because the zip should already be local. - shutil.rmtree('zips') + shutil.rmtree('downloads') checked_call_with_output(emsdk + ' install 2.0.28', expected='Downloading:', env=env) checked_call_with_output(emsdk + ' install 2.0.29', expected='Downloading:', env=env) checked_call_with_output(emsdk + ' install 2.0.28', expected='already downloaded, skipping', unexpected='Downloading:', env=env)