diff options
author | Anirudh Subramanian <anirudh2290@ufl.edu> | 2020-05-22 17:19:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-22 18:19:04 -0600 |
commit | 471a2ceaf3f0b77ca63003b196e8ba8c54283806 (patch) | |
tree | 09b43660c85c321391cdc12744cdb43a50c81ec6 | |
parent | fc92666e6331a0b9b7832a3ff0e6dd5b2822a0de (diff) | |
download | numpy-471a2ceaf3f0b77ca63003b196e8ba8c54283806.tar.gz |
MAINT: Cleanup 'tools/download-wheels.py' (#16329)
* ENH: Create download dir if not present for download-wheels
* TST: Add tests for download-wheels
* MAINT: use exist_ok=True for os.makedirs in download-wheels
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* MAINT: Remove test for download_wheels
* MAINT: Remove directory creation and error if dir not present
* MAINT: Print total files download and remove err for 0 search results
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
-rw-r--r-- | tools/download-wheels.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tools/download-wheels.py b/tools/download-wheels.py index 276fcc6b2..1e26e0e63 100644 --- a/tools/download-wheels.py +++ b/tools/download-wheels.py @@ -31,7 +31,7 @@ def get_wheel_names(version): """ http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED') - tmpl = re.compile(PREFIX + version + '.*\.whl$') + tmpl = re.compile(rf"{PREFIX}{version}.*\.whl$") index_url = f"{STAGING_URL}/files" index_html = http.request('GET', index_url) soup = BeautifulSoup(index_html.data, 'html.parser') @@ -54,13 +54,15 @@ def download_wheels(version, wheelhouse): """ http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED') wheel_names = get_wheel_names(version) - for wheel_name in wheel_names: + + for i, wheel_name in enumerate(wheel_names): wheel_url = f"{STAGING_URL}/{version}/download/{wheel_name}" wheel_path = os.path.join(wheelhouse, wheel_name) with open(wheel_path, 'wb') as f: with http.request('GET', wheel_url, preload_content=False,) as r: - print(f"Downloading {wheel_name}") + print(f"Downloading wheel {i + 1}, name: {wheel_name}") shutil.copyfileobj(r, f) + print(f"\nTotal files downloaded: {len(wheel_names)}") if __name__ == '__main__': @@ -77,4 +79,9 @@ if __name__ == '__main__': args = parser.parse_args() wheelhouse = os.path.expanduser(args.wheelhouse) + if not os.path.isdir(wheelhouse): + raise RuntimeError( + f"{wheelhouse} wheelhouse directory is not present." + " Perhaps you need to use the '-w' flag to specify one.") + download_wheels(args.version, wheelhouse) |