From 6b40c8ab057765279e4e74db36d7419b4d27c33f Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Fri, 12 Aug 2016 14:03:28 +0100 Subject: [PATCH 1/4] Add mirrors to freetype download Fixed build error due to gnu savannah being down --- setupext.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/setupext.py b/setupext.py index 83e2b9cd22de..0f3cab913d2b 100755 --- a/setupext.py +++ b/setupext.py @@ -1047,19 +1047,31 @@ 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 = ( + 'http://download.savannah.gnu.org/releases/freetype/{0}', + sourceforge_url + '{0}' + ) + for url_fmt in url_fmts: + 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') + try: + urlretrieve(tarball_url, tarball_path) + except: + print("Failed to download {0}".format(tarball_url)) + 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 From b3967e721e844e14273126abda99fdd1d8269c48 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Fri, 12 Aug 2016 14:04:47 +0100 Subject: [PATCH 2/4] make sure to break if download works --- setupext.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setupext.py b/setupext.py index 0f3cab913d2b..ceb147b86cb0 100755 --- a/setupext.py +++ b/setupext.py @@ -1070,6 +1070,8 @@ def do_custom_build(self): 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: From 8c304def3156a7b4d2c765c3c7d7ca8c403725ba Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Fri, 12 Aug 2016 14:07:14 +0100 Subject: [PATCH 3/4] refactor common code outside loop --- setupext.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/setupext.py b/setupext.py index ceb147b86cb0..27b93be139a1 100755 --- a/setupext.py +++ b/setupext.py @@ -1047,6 +1047,14 @@ def do_custom_build(self): pass if not os.path.isfile(tarball_path): + + 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') + sourceforge_url = ( 'http://downloads.sourceforge.net/project/freetype' '/freetype2/{0}/'.format(LOCAL_FREETYPE_VERSION) @@ -1059,13 +1067,6 @@ def do_custom_build(self): 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') try: urlretrieve(tarball_url, tarball_path) except: From 7509230395cb41afca0884effc15ca6000a5d061 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Mon, 15 Aug 2016 09:52:03 +0100 Subject: [PATCH 4/4] Reorder mirror and main source for freetype --- setupext.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setupext.py b/setupext.py index 27b93be139a1..5b84c0a4f121 100755 --- a/setupext.py +++ b/setupext.py @@ -1060,8 +1060,8 @@ def do_custom_build(self): '/freetype2/{0}/'.format(LOCAL_FREETYPE_VERSION) ) url_fmts = ( - 'http://download.savannah.gnu.org/releases/freetype/{0}', - sourceforge_url + '{0}' + sourceforge_url + '{0}', + 'http://download.savannah.gnu.org/releases/freetype/{0}' ) for url_fmt in url_fmts: tarball_url = url_fmt.format(tarball)