44# Written by Ivan Grokhotkov, 2015.
55#
66from __future__ import print_function
7- import urllib
87import os
98import shutil
109import errno
1615import tarfile
1716import zipfile
1817import re
18+ if sys .version_info [0 ] == 3 :
19+ from urllib .request import urlretrieve
20+ else :
21+ # Not Python 3 - today, it is most likely to be Python 2
22+ from urllib import urlretrieve
1923
2024dist_dir = 'dist/'
2125
@@ -54,7 +58,7 @@ def unpack(filename, destination):
5458 raise NotImplementedError ('Unsupported archive type' )
5559
5660 # a little trick to rename tool directories so they don't contain version number
57- rename_to = re .match (r'^([a-z][^\-]*\-*)+' , dirname ).group (0 ).encode ( 'ascii' ). strip ('-' )
61+ rename_to = re .match (r'^([a-z][^\-]*\-*)+' , dirname ).group (0 ).strip ('-' )
5862 if rename_to != dirname :
5963 print ('Renaming {0} to {1}' .format (dirname , rename_to ))
6064 if os .path .isdir (rename_to ):
@@ -68,7 +72,7 @@ def get_tool(tool):
6872 real_hash = tool ['checksum' ].split (':' )[1 ]
6973 if not os .path .isfile (local_path ):
7074 print ('Downloading ' + archive_name );
71- urllib . urlretrieve (url , local_path , report_progress )
75+ urlretrieve (url , local_path , report_progress )
7276 sys .stdout .write ("\r Done\n " )
7377 sys .stdout .flush ()
7478 else :
0 commit comments