@@ -177,7 +177,6 @@ def write_cache(local_fn, data):
177177options = {
178178 'display_status' : True ,
179179 'backend' : None ,
180- 'basedirlist' : None
181180 }
182181
183182
@@ -192,11 +191,6 @@ def write_cache(local_fn, data):
192191 if config .has_option ('rc_options' , 'backend' ):
193192 options ['backend' ] = config .get ("rc_options" , "backend" )
194193
195- if config .has_option ('directories' , 'basedirlist' ):
196- options ['basedirlist' ] = [
197- x .strip () for x in
198- config .get ("directories" , "basedirlist" ).split (',' )]
199-
200194 if config .has_option ('test' , 'local_freetype' ):
201195 options ['local_freetype' ] = config .getboolean ("test" , "local_freetype" )
202196else :
@@ -206,52 +200,6 @@ def write_cache(local_fn, data):
206200options ['local_freetype' ] = lft or options .get ('local_freetype' , False )
207201
208202
209- def get_base_dirs ():
210- """
211- Returns a list of standard base directories on this platform.
212- """
213- if options ['basedirlist' ]:
214- return options ['basedirlist' ]
215-
216- if os .environ .get ('MPLBASEDIRLIST' ):
217- return os .environ .get ('MPLBASEDIRLIST' ).split (os .pathsep )
218-
219- win_bases = ['win32_static' ]
220- # on conda windows, we also add the <conda_env_dir>\Library,
221- # as conda installs libs/includes there
222- # env var names mess: https://github.com/conda/conda/issues/2312
223- conda_env_path = os .getenv ('CONDA_PREFIX' ) # conda >= 4.1
224- if not conda_env_path :
225- conda_env_path = os .getenv ('CONDA_DEFAULT_ENV' ) # conda < 4.1
226- if conda_env_path and os .path .isdir (conda_env_path ):
227- win_bases .append (os .path .join (conda_env_path , "Library" ))
228-
229- basedir_map = {
230- 'win32' : win_bases ,
231- 'darwin' : ['/usr/local/' , '/usr' , '/usr/X11' ,
232- '/opt/X11' , '/opt/local' ],
233- 'sunos5' : [os .getenv ('MPLIB_BASE' ) or '/usr/local' , ],
234- 'gnu0' : ['/usr' ],
235- 'aix5' : ['/usr/local' ],
236- }
237- return basedir_map .get (sys .platform , ['/usr/local' , '/usr' ])
238-
239-
240- def get_include_dirs ():
241- """
242- Returns a list of standard include directories on this platform.
243- """
244- include_dirs = [os .path .join (d , 'include' ) for d in get_base_dirs ()]
245- if sys .platform != 'win32' :
246- # gcc includes these dirs automatically, so also look for headers in
247- # these dirs
248- include_dirs .extend (
249- os .environ .get ('CPATH' , '' ).split (os .pathsep ))
250- include_dirs .extend (
251- os .environ .get ('CPLUS_INCLUDE_PATH' , '' ).split (os .pathsep ))
252- return include_dirs
253-
254-
255203def is_min_version (found , minversion ):
256204 """
257205 Returns whether *found* is a version at least as high as *minversion*.
@@ -285,32 +233,6 @@ def print_line(*args, **kwargs):
285233 print_status = print_message = print_raw = print_line
286234
287235
288- def make_extension (name , files , * args , ** kwargs ):
289- """
290- Make a new extension. Automatically sets include_dirs and
291- library_dirs to the base directories appropriate for this
292- platform.
293-
294- `name` is the name of the extension.
295-
296- `files` is a list of source files.
297-
298- Any additional arguments are passed to the
299- `distutils.core.Extension` constructor.
300- """
301- ext = Extension (name , files , * args , ** kwargs )
302- for dir in get_base_dirs ():
303- include_dir = os .path .join (dir , 'include' )
304- if os .path .exists (include_dir ):
305- ext .include_dirs .append (include_dir )
306- for lib in ('lib' , 'lib64' ):
307- lib_dir = os .path .join (dir , lib )
308- if os .path .exists (lib_dir ):
309- ext .library_dirs .append (lib_dir )
310- ext .include_dirs .append ('.' )
311- return ext
312-
313-
314236def get_buffer_hash (fd ):
315237 BLOCKSIZE = 1 << 16
316238 hasher = hashlib .sha256 ()
@@ -354,8 +276,10 @@ def set_pkgconfig_path(self):
354276 def setup_extension (self , ext , package ,
355277 alt_exec = None , default_libraries = ()):
356278 """Add parameters to the given *ext* for the given *package*."""
357- cmd = ([self .pkg_config , package ] if self .pkg_config
358- else alt_exec )
279+
280+ # First, try to get the flags from pkg-config.
281+
282+ cmd = ([self .pkg_config , package ] if self .pkg_config else alt_exec )
359283 if cmd is not None :
360284 try :
361285 flags = shlex .split (subprocess .check_output (
@@ -371,7 +295,21 @@ def setup_extension(self, ext, package,
371295 ext .extra_compile_args .extend (flags )
372296 ext .extra_link_args .extend (flags )
373297 return
374- # Else, fall back on the defaults.
298+
299+ # If that fails, fall back on the defaults.
300+
301+ # conda Windows header and library paths.
302+ # https://github.com/conda/conda/issues/2312 re: getting the env dir.
303+ if sys .platform == 'win32' :
304+ conda_env_path = (os .getenv ('CONDA_PREFIX' ) # conda >= 4.1
305+ or os .getenv ('CONDA_DEFAULT_ENV' )) # conda < 4.1
306+ if conda_env_path and os .path .isdir (conda_env_path ):
307+ ext .include_dirs .append (os .fspath (
308+ pathlib .Path (conda_env_path , "Library/include" )))
309+ ext .library_dirs .append (os .fspath (
310+ pathlib .Path (conda_env_path , "Library/lib" )))
311+
312+ # Default linked libs.
375313 ext .libraries .extend (default_libraries )
376314
377315 def get_version (self , package ):
@@ -897,7 +835,7 @@ def get_extension(self):
897835 'src/mplutils.cpp' ,
898836 'src/py_converters.cpp' ,
899837 ]
900- ext = make_extension ('matplotlib.ft2font' , sources )
838+ ext = Extension ('matplotlib.ft2font' , sources )
901839 FreeType ().add_flags (ext )
902840 Numpy ().add_flags (ext )
903841 LibAgg ().add_flags (ext , add_sources = False )
@@ -921,7 +859,7 @@ def get_extension(self):
921859 'src/_png.cpp' ,
922860 'src/mplutils.cpp' ,
923861 ]
924- ext = make_extension ('matplotlib._png' , sources )
862+ ext = Extension ('matplotlib._png' , sources )
925863 pkg_config .setup_extension (
926864 ext , 'libpng' ,
927865 alt_exec = ['libpng-config' , '--cflags' , '--ldflags' ],
@@ -953,7 +891,7 @@ def get_extension(self):
953891 'extern/ttconv/pprdrv_tt2.cpp' ,
954892 'extern/ttconv/ttutil.cpp'
955893 ]
956- ext = make_extension ('matplotlib.ttconv' , sources )
894+ ext = Extension ('matplotlib.ttconv' , sources )
957895 Numpy ().add_flags (ext )
958896 ext .include_dirs .insert (0 , 'extern' )
959897 return ext
@@ -968,7 +906,7 @@ def get_extension(self):
968906 'src/_path_wrapper.cpp'
969907 ]
970908
971- ext = make_extension ('matplotlib._path' , sources )
909+ ext = Extension ('matplotlib._path' , sources )
972910 Numpy ().add_flags (ext )
973911 LibAgg ().add_flags (ext )
974912 return ext
@@ -984,7 +922,7 @@ def get_extension(self):
984922 'src/_image_wrapper.cpp' ,
985923 'src/py_converters.cpp'
986924 ]
987- ext = make_extension ('matplotlib._image' , sources )
925+ ext = Extension ('matplotlib._image' , sources )
988926 Numpy ().add_flags (ext )
989927 LibAgg ().add_flags (ext )
990928
@@ -1000,7 +938,7 @@ def get_extension(self):
1000938 "src/_contour_wrapper.cpp" ,
1001939 'src/py_converters.cpp' ,
1002940 ]
1003- ext = make_extension ('matplotlib._contour' , sources )
941+ ext = Extension ('matplotlib._contour' , sources )
1004942 Numpy ().add_flags (ext )
1005943 LibAgg ().add_flags (ext , add_sources = False )
1006944 return ext
@@ -1011,8 +949,8 @@ class QhullWrap(SetupPackage):
1011949
1012950 def get_extension (self ):
1013951 sources = ['src/qhull_wrap.c' ]
1014- ext = make_extension ('matplotlib._qhull' , sources ,
1015- define_macros = [('MPL_DEVNULL' , os .devnull )])
952+ ext = Extension ('matplotlib._qhull' , sources ,
953+ define_macros = [('MPL_DEVNULL' , os .devnull )])
1016954 Numpy ().add_flags (ext )
1017955 Qhull ().add_flags (ext )
1018956 return ext
@@ -1027,7 +965,7 @@ def get_extension(self):
1027965 "src/tri/_tri_wrapper.cpp" ,
1028966 "src/mplutils.cpp"
1029967 ]
1030- ext = make_extension ('matplotlib._tri' , sources )
968+ ext = Extension ('matplotlib._tri' , sources )
1031969 Numpy ().add_flags (ext )
1032970 return ext
1033971
@@ -1043,7 +981,7 @@ def get_extension(self):
1043981 "src/_backend_agg.cpp" ,
1044982 "src/_backend_agg_wrapper.cpp"
1045983 ]
1046- ext = make_extension ('matplotlib.backends._backend_agg' , sources )
984+ ext = Extension ('matplotlib.backends._backend_agg' , sources )
1047985 Numpy ().add_flags (ext )
1048986 LibAgg ().add_flags (ext )
1049987 FreeType ().add_flags (ext )
@@ -1063,7 +1001,7 @@ def get_extension(self):
10631001 'src/py_converters.cpp' ,
10641002 ]
10651003
1066- ext = make_extension ('matplotlib.backends._tkagg' , sources )
1004+ ext = Extension ('matplotlib.backends._tkagg' , sources )
10671005 self .add_flags (ext )
10681006 Numpy ().add_flags (ext )
10691007 LibAgg ().add_flags (ext , add_sources = False )
@@ -1094,7 +1032,7 @@ def get_extension(self):
10941032 'src/_macosx.m'
10951033 ]
10961034
1097- ext = make_extension ('matplotlib.backends._macosx' , sources )
1035+ ext = Extension ('matplotlib.backends._macosx' , sources )
10981036 ext .extra_link_args .extend (['-framework' , 'Cocoa' ])
10991037 if platform .python_implementation ().lower () == 'pypy' :
11001038 ext .extra_compile_args .append ('-DPYPY=1' )
0 commit comments