@@ -177,7 +177,6 @@ def write_cache(local_fn, data):
177
177
options = {
178
178
'display_status' : True ,
179
179
'backend' : None ,
180
- 'basedirlist' : None
181
180
}
182
181
183
182
@@ -192,11 +191,6 @@ def write_cache(local_fn, data):
192
191
if config .has_option ('rc_options' , 'backend' ):
193
192
options ['backend' ] = config .get ("rc_options" , "backend" )
194
193
195
- if config .has_option ('directories' , 'basedirlist' ):
196
- options ['basedirlist' ] = [
197
- x .strip () for x in
198
- config .get ("directories" , "basedirlist" ).split (',' )]
199
-
200
194
if config .has_option ('test' , 'local_freetype' ):
201
195
options ['local_freetype' ] = config .getboolean ("test" , "local_freetype" )
202
196
else :
@@ -206,52 +200,6 @@ def write_cache(local_fn, data):
206
200
options ['local_freetype' ] = lft or options .get ('local_freetype' , False )
207
201
208
202
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
-
255
203
def is_min_version (found , minversion ):
256
204
"""
257
205
Returns whether *found* is a version at least as high as *minversion*.
@@ -285,32 +233,6 @@ def print_line(*args, **kwargs):
285
233
print_status = print_message = print_raw = print_line
286
234
287
235
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
-
314
236
def get_buffer_hash (fd ):
315
237
BLOCKSIZE = 1 << 16
316
238
hasher = hashlib .sha256 ()
@@ -354,8 +276,10 @@ def set_pkgconfig_path(self):
354
276
def setup_extension (self , ext , package ,
355
277
alt_exec = None , default_libraries = ()):
356
278
"""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 )
359
283
if cmd is not None :
360
284
try :
361
285
flags = shlex .split (subprocess .check_output (
@@ -371,7 +295,21 @@ def setup_extension(self, ext, package,
371
295
ext .extra_compile_args .extend (flags )
372
296
ext .extra_link_args .extend (flags )
373
297
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.
375
313
ext .libraries .extend (default_libraries )
376
314
377
315
def get_version (self , package ):
@@ -897,7 +835,7 @@ def get_extension(self):
897
835
'src/mplutils.cpp' ,
898
836
'src/py_converters.cpp' ,
899
837
]
900
- ext = make_extension ('matplotlib.ft2font' , sources )
838
+ ext = Extension ('matplotlib.ft2font' , sources )
901
839
FreeType ().add_flags (ext )
902
840
Numpy ().add_flags (ext )
903
841
LibAgg ().add_flags (ext , add_sources = False )
@@ -921,7 +859,7 @@ def get_extension(self):
921
859
'src/_png.cpp' ,
922
860
'src/mplutils.cpp' ,
923
861
]
924
- ext = make_extension ('matplotlib._png' , sources )
862
+ ext = Extension ('matplotlib._png' , sources )
925
863
pkg_config .setup_extension (
926
864
ext , 'libpng' ,
927
865
alt_exec = ['libpng-config' , '--cflags' , '--ldflags' ],
@@ -953,7 +891,7 @@ def get_extension(self):
953
891
'extern/ttconv/pprdrv_tt2.cpp' ,
954
892
'extern/ttconv/ttutil.cpp'
955
893
]
956
- ext = make_extension ('matplotlib.ttconv' , sources )
894
+ ext = Extension ('matplotlib.ttconv' , sources )
957
895
Numpy ().add_flags (ext )
958
896
ext .include_dirs .insert (0 , 'extern' )
959
897
return ext
@@ -968,7 +906,7 @@ def get_extension(self):
968
906
'src/_path_wrapper.cpp'
969
907
]
970
908
971
- ext = make_extension ('matplotlib._path' , sources )
909
+ ext = Extension ('matplotlib._path' , sources )
972
910
Numpy ().add_flags (ext )
973
911
LibAgg ().add_flags (ext )
974
912
return ext
@@ -984,7 +922,7 @@ def get_extension(self):
984
922
'src/_image_wrapper.cpp' ,
985
923
'src/py_converters.cpp'
986
924
]
987
- ext = make_extension ('matplotlib._image' , sources )
925
+ ext = Extension ('matplotlib._image' , sources )
988
926
Numpy ().add_flags (ext )
989
927
LibAgg ().add_flags (ext )
990
928
@@ -1000,7 +938,7 @@ def get_extension(self):
1000
938
"src/_contour_wrapper.cpp" ,
1001
939
'src/py_converters.cpp' ,
1002
940
]
1003
- ext = make_extension ('matplotlib._contour' , sources )
941
+ ext = Extension ('matplotlib._contour' , sources )
1004
942
Numpy ().add_flags (ext )
1005
943
LibAgg ().add_flags (ext , add_sources = False )
1006
944
return ext
@@ -1011,8 +949,8 @@ class QhullWrap(SetupPackage):
1011
949
1012
950
def get_extension (self ):
1013
951
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 )])
1016
954
Numpy ().add_flags (ext )
1017
955
Qhull ().add_flags (ext )
1018
956
return ext
@@ -1027,7 +965,7 @@ def get_extension(self):
1027
965
"src/tri/_tri_wrapper.cpp" ,
1028
966
"src/mplutils.cpp"
1029
967
]
1030
- ext = make_extension ('matplotlib._tri' , sources )
968
+ ext = Extension ('matplotlib._tri' , sources )
1031
969
Numpy ().add_flags (ext )
1032
970
return ext
1033
971
@@ -1043,7 +981,7 @@ def get_extension(self):
1043
981
"src/_backend_agg.cpp" ,
1044
982
"src/_backend_agg_wrapper.cpp"
1045
983
]
1046
- ext = make_extension ('matplotlib.backends._backend_agg' , sources )
984
+ ext = Extension ('matplotlib.backends._backend_agg' , sources )
1047
985
Numpy ().add_flags (ext )
1048
986
LibAgg ().add_flags (ext )
1049
987
FreeType ().add_flags (ext )
@@ -1063,7 +1001,7 @@ def get_extension(self):
1063
1001
'src/py_converters.cpp' ,
1064
1002
]
1065
1003
1066
- ext = make_extension ('matplotlib.backends._tkagg' , sources )
1004
+ ext = Extension ('matplotlib.backends._tkagg' , sources )
1067
1005
self .add_flags (ext )
1068
1006
Numpy ().add_flags (ext )
1069
1007
LibAgg ().add_flags (ext , add_sources = False )
@@ -1094,7 +1032,7 @@ def get_extension(self):
1094
1032
'src/_macosx.m'
1095
1033
]
1096
1034
1097
- ext = make_extension ('matplotlib.backends._macosx' , sources )
1035
+ ext = Extension ('matplotlib.backends._macosx' , sources )
1098
1036
ext .extra_link_args .extend (['-framework' , 'Cocoa' ])
1099
1037
if platform .python_implementation ().lower () == 'pypy' :
1100
1038
ext .extra_compile_args .append ('-DPYPY=1' )
0 commit comments