Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 507aca5

Browse files
authored
Merge pull request #6943 from jenshnielsen/addfreetypemirror
BLD: Add mirrors to freetype download
2 parents 6937366 + 7509230 commit 507aca5

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

setupext.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,19 +1047,34 @@ def do_custom_build(self):
10471047
pass
10481048

10491049
if not os.path.isfile(tarball_path):
1050-
url_fmt = (
1051-
'http://download.savannah.gnu.org/releases/freetype/{0}')
1052-
tarball_url = url_fmt.format(tarball)
10531050

1054-
print("Downloading {0}".format(tarball_url))
10551051
if sys.version_info[0] == 2:
10561052
from urllib import urlretrieve
10571053
else:
10581054
from urllib.request import urlretrieve
1059-
10601055
if not os.path.exists('build'):
10611056
os.makedirs('build')
1062-
urlretrieve(tarball_url, tarball_path)
1057+
1058+
sourceforge_url = (
1059+
'http://downloads.sourceforge.net/project/freetype'
1060+
'/freetype2/{0}/'.format(LOCAL_FREETYPE_VERSION)
1061+
)
1062+
url_fmts = (
1063+
sourceforge_url + '{0}',
1064+
'http://download.savannah.gnu.org/releases/freetype/{0}'
1065+
)
1066+
for url_fmt in url_fmts:
1067+
tarball_url = url_fmt.format(tarball)
1068+
1069+
print("Downloading {0}".format(tarball_url))
1070+
try:
1071+
urlretrieve(tarball_url, tarball_path)
1072+
except:
1073+
print("Failed to download {0}".format(tarball_url))
1074+
else:
1075+
break
1076+
if not os.path.isfile(tarball_path):
1077+
raise IOError("Failed to download freetype")
10631078
if get_file_hash(tarball_path) == LOCAL_FREETYPE_HASH:
10641079
try:
10651080
# this will fail on LPy, oh well

0 commit comments

Comments
 (0)