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

Skip to content

Commit 3306021

Browse files
authored
Merge pull request #13455 from tacaswell/fix_freetype_download_logic
BLD: only try to get freetype src if src does not exist
2 parents a33422b + 2ff0f71 commit 3306021

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

setupext.py

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -960,43 +960,51 @@ def do_custom_build(self):
960960
else:
961961
libfreetype = 'libfreetype.a'
962962

963-
if os.path.isfile(os.path.join(src_path, 'objs', '.libs', libfreetype)):
963+
# bailing because it is already built
964+
if os.path.isfile(os.path.join(
965+
src_path, 'objs', '.libs', libfreetype)):
964966
return
965-
if not os.path.exists('build'):
966-
os.makedirs('build')
967-
968-
url_fmts = [
969-
('https://downloads.sourceforge.net/project/freetype'
970-
'/freetype2/{version}/{tarball}'),
971-
('https://download.savannah.gnu.org/releases/freetype'
972-
'/{tarball}')
973-
]
974-
tarball = 'freetype-{0}.tar.gz'.format(LOCAL_FREETYPE_VERSION)
975-
976-
target_urls = [
977-
url_fmt.format(version=LOCAL_FREETYPE_VERSION,
978-
tarball=tarball)
979-
for url_fmt in url_fmts]
980-
981-
for tarball_url in target_urls:
982-
try:
983-
tar_contents = download_or_cache(tarball_url,
984-
LOCAL_FREETYPE_HASH)
985-
break
986-
except Exception:
987-
pass
988-
else:
989-
raise IOError("Failed to download FreeType. Please download " +
990-
"one of {target_urls} ".format(
991-
target_urls=target_urls) +
992-
"and extract it into the build directory "
993-
"at the top-level of the source repository")
994967

995-
print("Building {}".format(tarball))
996-
tar_contents.seek(0)
997-
with tarfile.open(tarball, mode="r:gz", fileobj=tar_contents) as tgz:
998-
tgz.extractall("build")
968+
# do we need to download / load the source from cache?
969+
if not os.path.exists(src_path):
970+
if not os.path.exists('build'):
971+
os.makedirs('build')
999972

973+
url_fmts = [
974+
('https://downloads.sourceforge.net/project/freetype'
975+
'/freetype2/{version}/{tarball}'),
976+
('https://download.savannah.gnu.org/releases/freetype'
977+
'/{tarball}')
978+
]
979+
tarball = 'freetype-{0}.tar.gz'.format(LOCAL_FREETYPE_VERSION)
980+
981+
target_urls = [
982+
url_fmt.format(version=LOCAL_FREETYPE_VERSION,
983+
tarball=tarball)
984+
for url_fmt in url_fmts]
985+
986+
for tarball_url in target_urls:
987+
try:
988+
tar_contents = download_or_cache(tarball_url,
989+
LOCAL_FREETYPE_HASH)
990+
break
991+
except Exception:
992+
pass
993+
else:
994+
raise IOError("Failed to download FreeType. Please download "
995+
"one of {target_urls} and extract it into "
996+
"{src_path} at the top-level of the source "
997+
"repository".format(
998+
target_urls=target_urls, src_path=src_path))
999+
1000+
print("Extracting {}".format(tarball))
1001+
# just to be sure
1002+
tar_contents.seek(0)
1003+
with tarfile.open(tarball, mode="r:gz",
1004+
fileobj=tar_contents) as tgz:
1005+
tgz.extractall("build")
1006+
1007+
print("Building freetype in {}".format(src_path))
10001008
if sys.platform != 'win32':
10011009
# compilation on all other platforms than windows
10021010
env = {**os.environ,

0 commit comments

Comments
 (0)