@@ -1147,43 +1147,51 @@ def do_custom_build(self):
11471147 else :
11481148 libfreetype = 'libfreetype.a'
11491149
1150- if os .path .isfile (os .path .join (src_path , 'objs' , '.libs' , libfreetype )):
1150+ # bailing because it is already built
1151+ if os .path .isfile (os .path .join (
1152+ src_path , 'objs' , '.libs' , libfreetype )):
11511153 return
1152- if not os .path .exists ('build' ):
1153- os .makedirs ('build' )
1154-
1155- url_fmts = [
1156- ('https://downloads.sourceforge.net/project/freetype'
1157- '/freetype2/{version}/{tarball}' ),
1158- ('https://download.savannah.gnu.org/releases/freetype'
1159- '/{tarball}' )
1160- ]
1161- tarball = 'freetype-{0}.tar.gz' .format (LOCAL_FREETYPE_VERSION )
1162-
1163- target_urls = [
1164- url_fmt .format (version = LOCAL_FREETYPE_VERSION ,
1165- tarball = tarball )
1166- for url_fmt in url_fmts ]
1167-
1168- for tarball_url in target_urls :
1169- try :
1170- tar_contents = download_or_cache (tarball_url ,
1171- LOCAL_FREETYPE_HASH )
1172- break
1173- except Exception :
1174- pass
1175- else :
1176- raise IOError ("Failed to download FreeType. Please download " +
1177- "one of {target_urls} " .format (
1178- target_urls = target_urls ) +
1179- "and extract it into the build directory "
1180- "at the top-level of the source repository" )
11811154
1182- print ( "Building {}" . format ( tarball ))
1183- tar_contents . seek ( 0 )
1184- with tarfile . open ( tarball , mode = "r:gz" , fileobj = tar_contents ) as tgz :
1185- tgz . extractall ( " build" )
1155+ # do we need to download / load the source from cache?
1156+ if not os . path . exists ( src_path ):
1157+ if not os . path . exists ( 'build' ) :
1158+ os . makedirs ( ' build' )
11861159
1160+ url_fmts = [
1161+ ('https://downloads.sourceforge.net/project/freetype'
1162+ '/freetype2/{version}/{tarball}' ),
1163+ ('https://download.savannah.gnu.org/releases/freetype'
1164+ '/{tarball}' )
1165+ ]
1166+ tarball = 'freetype-{0}.tar.gz' .format (LOCAL_FREETYPE_VERSION )
1167+
1168+ target_urls = [
1169+ url_fmt .format (version = LOCAL_FREETYPE_VERSION ,
1170+ tarball = tarball )
1171+ for url_fmt in url_fmts ]
1172+
1173+ for tarball_url in target_urls :
1174+ try :
1175+ tar_contents = download_or_cache (tarball_url ,
1176+ LOCAL_FREETYPE_HASH )
1177+ break
1178+ except Exception :
1179+ pass
1180+ else :
1181+ raise IOError ("Failed to download FreeType. Please download "
1182+ "one of {target_urls} and extract it into "
1183+ "{src_path} at the top-level of the source "
1184+ "repository" .format (
1185+ target_urls = target_urls , src_path = src_path ))
1186+
1187+ print ("Extracting {}" .format (tarball ))
1188+ # just to be sure
1189+ tar_contents .seek (0 )
1190+ with tarfile .open (tarball , mode = "r:gz" ,
1191+ fileobj = tar_contents ) as tgz :
1192+ tgz .extractall ("build" )
1193+
1194+ print ("Building freetype in {}" .format (src_path ))
11871195 if sys .platform != 'win32' :
11881196 # compilation on all other platforms than windows
11891197 env = {** os .environ ,
0 commit comments