diff --git a/setupext.py b/setupext.py index 83e2b9cd22de..5b84c0a4f121 100755 --- a/setupext.py +++ b/setupext.py @@ -1047,19 +1047,34 @@ def do_custom_build(self): pass if not os.path.isfile(tarball_path): - url_fmt = ( - 'http://download.savannah.gnu.org/releases/freetype/{0}') - tarball_url = url_fmt.format(tarball) - print("Downloading {0}".format(tarball_url)) if sys.version_info[0] == 2: from urllib import urlretrieve else: from urllib.request import urlretrieve - if not os.path.exists('build'): os.makedirs('build') - urlretrieve(tarball_url, tarball_path) + + sourceforge_url = ( + 'http://downloads.sourceforge.net/project/freetype' + '/freetype2/{0}/'.format(LOCAL_FREETYPE_VERSION) + ) + url_fmts = ( + sourceforge_url + '{0}', + 'http://download.savannah.gnu.org/releases/freetype/{0}' + ) + for url_fmt in url_fmts: + tarball_url = url_fmt.format(tarball) + + print("Downloading {0}".format(tarball_url)) + try: + urlretrieve(tarball_url, tarball_path) + except: + print("Failed to download {0}".format(tarball_url)) + else: + break + if not os.path.isfile(tarball_path): + raise IOError("Failed to download freetype") if get_file_hash(tarball_path) == LOCAL_FREETYPE_HASH: try: # this will fail on LPy, oh well