Skip to content
This repository was archived by the owner on Jun 12, 2023. It is now read-only.

Commit c88d679

Browse files
authored
Merge pull request #23 from datapythonista/download_wheels
2 parents a7cbfb9 + e2b1598 commit c88d679

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ wheels:
153153

154154

155155
download-wheels:
156-
cd pandas && python scripts/download_wheels.py $(PANDAS_VERSION)
156+
./scripts/download_wheels.py $(PANDAS_VERSION)
157157
# TODO: Fetch from https://www.lfd.uci.edu/~gohlke/pythonlibs/
158158

159159

scripts/download_wheels.py

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

0 commit comments

Comments
 (0)