@@ -56,15 +56,20 @@ def get_wheel_names(version):
56
56
The release version. For instance, "1.18.3".
57
57
58
58
"""
59
+ ret = []
59
60
http = urllib3 .PoolManager (cert_reqs = "CERT_REQUIRED" )
60
61
tmpl = re .compile (rf"^.*{ PREFIX } -{ version } { SUFFIX } " )
61
- index_url = f"{ STAGING_URL } /files"
62
- index_html = http .request ("GET" , index_url )
63
- soup = BeautifulSoup (index_html .data , "html.parser" )
64
- return soup .find_all (string = tmpl )
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
65
70
66
71
67
- def download_wheels (version , wheelhouse ):
72
+ def download_wheels (version , wheelhouse , test = False ):
68
73
"""Download release wheels.
69
74
70
75
The release wheels for the given NumPy version are downloaded
@@ -86,8 +91,15 @@ def download_wheels(version, wheelhouse):
86
91
wheel_path = os .path .join (wheelhouse , wheel_name )
87
92
with open (wheel_path , "wb" ) as f :
88
93
with http .request ("GET" , wheel_url , preload_content = False ,) as r :
89
- print (f"{ i + 1 :<4} { wheel_name } " )
90
- shutil .copyfileobj (r , f )
94
+ info = r .info ()
95
+ length = int (info .get ('Content-Length' , '0' ))
96
+ if length == 0 :
97
+ length = 'unknown size'
98
+ else :
99
+ length = f"{ (length / 1024 / 1024 ):.2f} MB"
100
+ print (f"{ i + 1 :<4} { wheel_name } { length } " )
101
+ if not test :
102
+ shutil .copyfileobj (r , f )
91
103
print (f"\n Total files downloaded: { len (wheel_names )} " )
92
104
93
105
@@ -101,6 +113,10 @@ def download_wheels(version, wheelhouse):
101
113
default = os .path .join (os .getcwd (), "release" , "installers" ),
102
114
help = "Directory in which to store downloaded wheels\n "
103
115
"[defaults to <cwd>/release/installers]" )
116
+ parser .add_argument (
117
+ "-t" , "--test" ,
118
+ action = 'store_true' ,
119
+ help = "only list available wheels, do not download" )
104
120
105
121
args = parser .parse_args ()
106
122
@@ -110,4 +126,4 @@ def download_wheels(version, wheelhouse):
110
126
f"{ wheelhouse } wheelhouse directory is not present."
111
127
" Perhaps you need to use the '-w' flag to specify one." )
112
128
113
- download_wheels (args .version , wheelhouse )
129
+ download_wheels (args .version , wheelhouse , test = args . test )
0 commit comments