182182 basedirlist = basedir [sys .platform ]
183183print ("basedirlist is: %s" % basedirlist )
184184
185+ def make_extension (* args , ** kwargs ):
186+ ext = Extension (* args , ** kwargs )
187+ for dir in basedirlist :
188+ ext .include_dirs .append (os .path .join (dir , 'include' ))
189+ return ext
190+
185191if options ['display_status' ]:
186192 def print_line (char = '=' ):
187193 print (char * 76 )
@@ -321,7 +327,7 @@ def find_include_file(include_dirs, filename):
321327 return False
322328
323329def check_for_freetype ():
324- module = Extension ('test' , [])
330+ module = make_extension ('test' , [])
325331 add_base_flags (module )
326332 if not get_pkgconfig (module , 'freetype2' ):
327333 basedirs = module .include_dirs [:] # copy the list to avoid inf loop!
@@ -337,7 +343,7 @@ def check_for_freetype():
337343 return True
338344
339345def check_for_libpng ():
340- module = Extension ("test" , [])
346+ module = make_extension ("test" , [])
341347 get_pkgconfig (module , 'libpng' )
342348 add_base_flags (module )
343349
@@ -529,7 +535,7 @@ def check_for_numpy():
529535 'numpy 1.1 or later is required; you have %s' %
530536 numpy .__version__ )
531537 return False
532- module = Extension ('test' , [])
538+ module = make_extension ('test' , [])
533539 add_numpy_flags (module )
534540 add_base_flags (module )
535541
@@ -609,7 +615,7 @@ def check_for_gtk():
609615 gotit = True
610616
611617 if gotit :
612- module = Extension ('test' , [])
618+ module = make_extension ('test' , [])
613619 add_pygtk_flags (module )
614620 if not find_include_file (module .include_dirs , os .path .join ("gtk" , "gtk.h" )):
615621 explanation = (
@@ -714,7 +720,10 @@ def check_for_tk():
714720 gotit = False
715721 explanation = None
716722 try :
717- import Tkinter
723+ if sys .version_info [0 ] < 3 :
724+ import Tkinter
725+ else :
726+ import tkinter as Tkinter
718727 except ImportError :
719728 explanation = 'TKAgg requires Tkinter'
720729 except RuntimeError :
@@ -726,18 +735,18 @@ def check_for_tk():
726735 gotit = True
727736
728737 if gotit :
729- module = Extension ('test' , [])
738+ module = make_extension ('test' , [])
730739 try :
731740 explanation = add_tk_flags (module )
732- except RuntimeError :
733- # This deals with the change in exception handling syntax in
734- # python 3. If we only need to support >= 2.6, we can just use the
735- # commented out lines below.
736- exc_type ,exc ,tb = sys .exc_info ()
737- explanation = str (exc )
738- gotit = False
739- # except RuntimeError, e:
740- # explanation = str(e)
741+ # except RuntimeError:
742+ # # This deals with the change in exception handling syntax in
743+ # # python 3. If we only need to support >= 2.6, we can just use the
744+ # # commented out lines below.
745+ # exc_type,exc,tb = sys.exc_info()
746+ # explanation = str(exc)
747+ # gotit = False
748+ except RuntimeError as e :
749+ explanation = str (e )
741750 else :
742751 if not find_include_file (module .include_dirs , "tk.h" ):
743752 message = 'Tkinter present, but header files are not found. ' + \
@@ -1029,7 +1038,7 @@ def build_windowing(ext_modules, packages):
10291038 windows better, .e.g. maintaining focus on win32"""
10301039 global BUILT_WINDOWING
10311040 if BUILT_WINDOWING : return # only build it if you you haven't already
1032- module = Extension ('matplotlib._windowing' ,
1041+ module = make_extension ('matplotlib._windowing' ,
10331042 ['src/_windowing.cpp' ],
10341043 )
10351044 add_windowing_flags (module )
@@ -1043,7 +1052,7 @@ def build_ft2font(ext_modules, packages):
10431052 deps .extend (glob .glob ('CXX/*.cxx' ))
10441053 deps .extend (glob .glob ('CXX/*.c' ))
10451054
1046- module = Extension ('matplotlib.ft2font' , deps ,
1055+ module = make_extension ('matplotlib.ft2font' , deps ,
10471056 define_macros = defines )
10481057 add_ft2font_flags (module )
10491058 ext_modules .append (module )
@@ -1057,7 +1066,7 @@ def build_ttconv(ext_modules, packages):
10571066 'ttconv/pprdrv_tt2.cpp' ,
10581067 'ttconv/ttutil.cpp' ]
10591068
1060- module = Extension ('matplotlib.ttconv' , deps ,
1069+ module = make_extension ('matplotlib.ttconv' , deps ,
10611070 define_macros = defines )
10621071 add_base_flags (module )
10631072 ext_modules .append (module )
@@ -1070,7 +1079,7 @@ def build_gtkagg(ext_modules, packages):
10701079 deps .extend (glob .glob ('CXX/*.cxx' ))
10711080 deps .extend (glob .glob ('CXX/*.c' ))
10721081
1073- module = Extension ('matplotlib.backends._gtkagg' ,
1082+ module = make_extension ('matplotlib.backends._gtkagg' ,
10741083 deps ,
10751084 define_macros = defines
10761085 )
@@ -1093,7 +1102,7 @@ def build_tkagg(ext_modules, packages):
10931102 deps .extend (glob .glob ('CXX/*.cxx' ))
10941103 deps .extend (glob .glob ('CXX/*.c' ))
10951104
1096- module = Extension ('matplotlib.backends._tkagg' ,
1105+ module = make_extension ('matplotlib.backends._tkagg' ,
10971106 deps ,
10981107 define_macros = defines
10991108 )
@@ -1116,7 +1125,7 @@ def build_macosx(ext_modules, packages):
11161125 'CXX/IndirectPythonInterface.cxx' ,
11171126 'src/agg_py_transforms.cpp' ,
11181127 'src/path_cleanup.cpp' ]
1119- module = Extension ('matplotlib.backends._macosx' ,
1128+ module = make_extension ('matplotlib.backends._macosx' ,
11201129 deps ,
11211130 extra_link_args = ['-framework' ,'Cocoa' ],
11221131 define_macros = defines
@@ -1134,7 +1143,7 @@ def build_png(ext_modules, packages):
11341143 deps .extend (glob .glob ('CXX/*.cxx' ))
11351144 deps .extend (glob .glob ('CXX/*.c' ))
11361145
1137- module = Extension (
1146+ module = make_extension (
11381147 'matplotlib._png' ,
11391148 deps ,
11401149 include_dirs = numpy_inc_dirs ,
@@ -1166,7 +1175,7 @@ def build_agg(ext_modules, packages):
11661175 deps .extend (glob .glob ('CXX/*.c' ))
11671176 temp_copy ('src/_backend_agg.cpp' , 'src/backend_agg.cpp' )
11681177 deps .append ('src/backend_agg.cpp' )
1169- module = Extension (
1178+ module = make_extension (
11701179 'matplotlib.backends._backend_agg' ,
11711180 deps ,
11721181 include_dirs = numpy_inc_dirs ,
@@ -1199,7 +1208,7 @@ def build_path(ext_modules, packages):
11991208 deps .extend (['src/agg_py_transforms.cpp' ,
12001209 'src/path_cleanup.cpp' ,
12011210 'src/path.cpp' ])
1202- module = Extension (
1211+ module = make_extension (
12031212 'matplotlib._path' ,
12041213 deps ,
12051214 include_dirs = numpy_inc_dirs ,
@@ -1228,7 +1237,7 @@ def build_image(ext_modules, packages):
12281237 deps .extend (glob .glob ('CXX/*.cxx' ))
12291238 deps .extend (glob .glob ('CXX/*.c' ))
12301239
1231- module = Extension (
1240+ module = make_extension (
12321241 'matplotlib._image' ,
12331242 deps ,
12341243 include_dirs = numpy_inc_dirs ,
@@ -1251,7 +1260,7 @@ def build_delaunay(ext_modules, packages):
12511260 sourcefiles = ["_delaunay.cpp" , "VoronoiDiagramGenerator.cpp" ,
12521261 "delaunay_utils.cpp" , "natneighbors.cpp" ]
12531262 sourcefiles = [os .path .join ('lib/matplotlib/delaunay' ,s ) for s in sourcefiles ]
1254- delaunay = Extension ('matplotlib._delaunay' ,sourcefiles ,
1263+ delaunay = make_extension ('matplotlib._delaunay' ,sourcefiles ,
12551264 include_dirs = numpy_inc_dirs ,
12561265 define_macros = defines
12571266 )
@@ -1266,7 +1275,7 @@ def build_contour(ext_modules, packages):
12661275 global BUILT_CONTOUR
12671276 if BUILT_CONTOUR : return # only build it if you you haven't already
12681277
1269- module = Extension (
1278+ module = make_extension (
12701279 'matplotlib._cntr' ,
12711280 [ 'src/cntr.c' ],
12721281 include_dirs = numpy_inc_dirs ,
@@ -1284,7 +1293,7 @@ def build_gdk(ext_modules, packages):
12841293 if BUILT_GDK : return # only build it if you you haven't already
12851294
12861295 temp_copy ('src/_backend_gdk.c' , 'src/backend_gdk.c' )
1287- module = Extension (
1296+ module = make_extension (
12881297 'matplotlib.backends._backend_gdk' ,
12891298 ['src/backend_gdk.c' ],
12901299 libraries = [],
@@ -1308,7 +1317,7 @@ def build_tri(ext_modules, packages):
13081317 deps .extend (glob .glob ('CXX/*.cxx' ))
13091318 deps .extend (glob .glob ('CXX/*.c' ))
13101319
1311- module = Extension ('matplotlib._tri' , deps ,
1320+ module = make_extension ('matplotlib._tri' , deps ,
13121321 define_macros = defines )
13131322 add_numpy_flags (module )
13141323 add_base_flags (module )
0 commit comments