Skip to content

Commit 36b8753

Browse files
TomAugspurgerjreback
authored andcommitted
Added script to fetch wheels [ci skip] (#20928)
1 parent 83a46ca commit 36b8753

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

scripts/download_wheels.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""Fetch wheels from wheels.scipy.org for a pandas version."""
2+
import argparse
3+
import pathlib
4+
import sys
5+
import urllib.parse
6+
import urllib.request
7+
8+
from lxml import html
9+
10+
11+
def parse_args(args=None):
12+
parser = argparse.ArgumentParser(description=__doc__)
13+
parser.add_argument("version", type=str, help="Pandas version (0.23.0)")
14+
return parser.parse_args(args)
15+
16+
17+
def fetch(version):
18+
base = 'http://wheels.scipy.org'
19+
tree = html.parse(base)
20+
root = tree.getroot()
21+
22+
dest = pathlib.Path('dist')
23+
dest.mkdir(exist_ok=True)
24+
25+
files = [x for x in root.xpath("//a/text()")
26+
if x.startswith(f'pandas-{version}')
27+
and not dest.joinpath(x).exists()]
28+
29+
N = len(files)
30+
31+
for i, filename in enumerate(files, 1):
32+
out = str(dest.joinpath(filename))
33+
link = urllib.request.urljoin(base, filename)
34+
urllib.request.urlretrieve(link, out)
35+
print(f"Downloaded {link} to {out} [{i}/{N}]")
36+
37+
38+
def main(args=None):
39+
args = parse_args(args)
40+
fetch(args.version)
41+
42+
43+
if __name__ == '__main__':
44+
sys.exit(main())

0 commit comments

Comments
 (0)