Skip to content

Commit 6937849

Browse files
authored
Merge pull request #247 from mattip/download
update download script
2 parents 889ec4e + 718513b commit 6937849

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

tools/download-wheels.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,8 @@
3434
__version__ = "0.1"
3535

3636
# Edit these for other projects.
37-
URL = "https://anaconda.org/scientific-python-nightly-wheels"
38-
39-
# Name endings of the files to download.
40-
WHL = r"-.*\.whl$"
41-
ZIP = r"\.zip$"
42-
GZIP = r"\.tar\.gz$"
43-
SUFFIX = rf"({WHL}|{GZIP}|{ZIP})"
37+
SIMPLE_INDEX = "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"
38+
BASE = "https://pypi.anaconda.org"
4439

4540

4641
def get_wheel_names(package, version):
@@ -56,11 +51,12 @@ def get_wheel_names(package, version):
5651
5752
"""
5853
http = urllib3.PoolManager(cert_reqs="CERT_REQUIRED")
59-
tmpl = re.compile(rf"^.*{package.replace('-', '_')}-{version}{SUFFIX}")
60-
index_url = f"{URL}/{package}/files"
54+
index_url = f"{SIMPLE_INDEX}/{package}"
55+
print(f"looking in {index_url}")
6156
index_html = http.request("GET", index_url)
6257
soup = BeautifulSoup(index_html.data, "html.parser")
63-
return soup.find_all(string=tmpl)
58+
breakpoint()
59+
return [xxx['href'] for xxx in soup.find_all('a', href=True) if version in str(xxx)]
6460

6561

6662
def download_wheels(package, version, wheelhouse, test=False):
@@ -83,8 +79,9 @@ def download_wheels(package, version, wheelhouse, test=False):
8379
wheel_names = get_wheel_names(package, version)
8480

8581
for i, wheel_name in enumerate(wheel_names):
86-
wheel_url = f"{URL}/{package}/{version}/download/{wheel_name}"
87-
wheel_path = os.path.join(wheelhouse, wheel_name)
82+
wheel_url = f"{BASE}/{wheel_name}"
83+
wheel_file = wheel_name.split('/')[-1]
84+
wheel_path = os.path.join(wheelhouse, wheel_file)
8885
with open(wheel_path, "wb") as f:
8986
with http.request("GET", wheel_url, preload_content=False,) as r:
9087
info = r.info()
@@ -93,7 +90,7 @@ def download_wheels(package, version, wheelhouse, test=False):
9390
length = 'unknown size'
9491
else:
9592
length = f"{(length / 1024 / 1024):.2f}MB"
96-
print(f"{i + 1:<4}{wheel_name} {length}")
93+
print(f"{i + 1:<4}{wheel_file} {length}")
9794
if not test:
9895
shutil.copyfileobj(r, f)
9996
print(f"\nTotal files downloaded: {len(wheel_names)}")

0 commit comments

Comments
 (0)