From 5221d200f2895bdbfcaa45f0a3dff52b3645d568 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 2 May 2018 11:20:16 -0500 Subject: [PATCH 1/2] Added script to fetch wheels [ci skip] [ci skip] --- scripts/download_wheels.py | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 scripts/download_wheels.py diff --git a/scripts/download_wheels.py b/scripts/download_wheels.py new file mode 100644 index 0000000000000..00ed4d81bfa20 --- /dev/null +++ b/scripts/download_wheels.py @@ -0,0 +1,43 @@ +"""Fetch wheels from wheels.scipy.org for a pandas version.""" +import argparse +import pathlib +import sys +import urllib.parse +import urllib.request + +from lxml import html + + +def parse_args(args=None): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("version", type=str, help="Pandas version (0.23.0)") + return parser.parse_args(args) + + +def fetch(version): + base = 'http://wheels.scipy.org' + tree = html.parse(base) + root = tree.getroot() + + dest = pathlib.Path('dist') + dest.mkdir(exist_ok=True) + + files = [x for x in root.xpath("//a/text()") + if x.startswith(f'pandas-{version}') + and not pathlib.Path('dist', x).exists()] + + N = len(files) + + for i, filename in enumerate(files, 1): + link = urllib.request.urljoin(base, filename) + urllib.request.urlretrieve(link, filename) + print(f"Downloaded {link} to {filename} [{i}/{N}]") + + +def main(args=None): + args = parse_args(args) + fetch(args.version) + + +if __name__ == '__main__': + sys.exit(main()) From 6385d8cbb886a044ff774150ed3cf45d493bc196 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 2 May 2018 12:14:21 -0500 Subject: [PATCH 2/2] Fixup [ci skip] [ci skip] --- scripts/download_wheels.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/download_wheels.py b/scripts/download_wheels.py index 00ed4d81bfa20..a4705d0e4e63c 100644 --- a/scripts/download_wheels.py +++ b/scripts/download_wheels.py @@ -24,14 +24,15 @@ def fetch(version): files = [x for x in root.xpath("//a/text()") if x.startswith(f'pandas-{version}') - and not pathlib.Path('dist', x).exists()] + and not dest.joinpath(x).exists()] N = len(files) for i, filename in enumerate(files, 1): + out = str(dest.joinpath(filename)) link = urllib.request.urljoin(base, filename) - urllib.request.urlretrieve(link, filename) - print(f"Downloaded {link} to {filename} [{i}/{N}]") + urllib.request.urlretrieve(link, out) + print(f"Downloaded {link} to {out} [{i}/{N}]") def main(args=None):