31
31
import urllib3
32
32
from bs4 import BeautifulSoup
33
33
34
- __version__ = "0.1 "
34
+ __version__ = "0.2 "
35
35
36
36
# Edit these for other projects.
37
- STAGING_URL = "https://anaconda.org/multibuild-wheels-staging/numpy"
37
+
38
+ # The first URL is used to get the file names as it avoids the need for paging
39
+ # when the number of files exceeds the page length. Note that files/page is not
40
+ # stable and can change when the page layout changes. The second URL is used to
41
+ # retrieve the files themselves. This workaround is copied from SciPy.
42
+ NAMES_URL = "https://pypi.anaconda.org/multibuild-wheels-staging/simple/numpy/"
43
+ FILES_URL = "https://anaconda.org/multibuild-wheels-staging/numpy"
44
+
45
+ # Name prefix of the files to download.
38
46
PREFIX = "numpy"
39
47
40
48
# Name endings of the files to download.
@@ -56,17 +64,12 @@ def get_wheel_names(version):
56
64
The release version. For instance, "1.18.3".
57
65
58
66
"""
59
- ret = []
60
67
http = urllib3 .PoolManager (cert_reqs = "CERT_REQUIRED" )
61
68
tmpl = re .compile (rf"^.*{ PREFIX } -{ version } { SUFFIX } " )
62
- # TODO: generalize this by searching for `showing 1 of N` and
63
- # looping over N pages, starting from 1
64
- for i in range (1 ,3 ):
65
- index_url = f"{ STAGING_URL } /files?page={ i } "
66
- index_html = http .request ("GET" ,index_url )
67
- soup = BeautifulSoup (index_html .data ,"html.parser" )
68
- ret += soup .find_all (string = tmpl )
69
- return ret
69
+ index_url = f"{ NAMES_URL } "
70
+ index_html = http .request ('GET' ,index_url )
71
+ soup = BeautifulSoup (index_html .data ,'html.parser' )
72
+ return sorted (soup .find_all (string = tmpl ))
70
73
71
74
72
75
def download_wheels (version ,wheelhouse ,test = False ):
@@ -87,7 +90,7 @@ def download_wheels(version, wheelhouse, test=False):
87
90
wheel_names = get_wheel_names (version )
88
91
89
92
for i ,wheel_name in enumerate (wheel_names ):
90
- wheel_url = f"{ STAGING_URL } /{ version } /download/{ wheel_name } "
93
+ wheel_url = f"{ FILES_URL } /{ version } /download/{ wheel_name } "
91
94
wheel_path = os .path .join (wheelhouse ,wheel_name )
92
95
with open (wheel_path ,"wb" )as f :
93
96
with http .request ("GET" ,wheel_url ,preload_content = False ,)as r :