@@ -61,7 +61,6 @@ def _get_xdg_cache_dir():
61
61
options = {
62
62
'display_status' : True ,
63
63
'backend' : None ,
64
- 'basedirlist' : None
65
64
}
66
65
67
66
@@ -76,11 +75,6 @@ def _get_xdg_cache_dir():
76
75
if config .has_option ('rc_options' , 'backend' ):
77
76
options ['backend' ] = config .get ("rc_options" , "backend" )
78
77
79
- if config .has_option ('directories' , 'basedirlist' ):
80
- options ['basedirlist' ] = [
81
- x .strip () for x in
82
- config .get ("directories" , "basedirlist" ).split (',' )]
83
-
84
78
if config .has_option ('test' , 'local_freetype' ):
85
79
options ['local_freetype' ] = config .getboolean ("test" , "local_freetype" )
86
80
else :
@@ -90,52 +84,6 @@ def _get_xdg_cache_dir():
90
84
options ['local_freetype' ] = lft or options .get ('local_freetype' , False )
91
85
92
86
93
- def get_base_dirs ():
94
- """
95
- Returns a list of standard base directories on this platform.
96
- """
97
- if options ['basedirlist' ]:
98
- return options ['basedirlist' ]
99
-
100
- if os .environ .get ('MPLBASEDIRLIST' ):
101
- return os .environ .get ('MPLBASEDIRLIST' ).split (os .pathsep )
102
-
103
- win_bases = ['win32_static' ]
104
- # on conda windows, we also add the <conda_env_dir>\Library,
105
- # as conda installs libs/includes there
106
- # env var names mess: https://github.com/conda/conda/issues/2312
107
- conda_env_path = os .getenv ('CONDA_PREFIX' ) # conda >= 4.1
108
- if not conda_env_path :
109
- conda_env_path = os .getenv ('CONDA_DEFAULT_ENV' ) # conda < 4.1
110
- if conda_env_path and os .path .isdir (conda_env_path ):
111
- win_bases .append (os .path .join (conda_env_path , "Library" ))
112
-
113
- basedir_map = {
114
- 'win32' : win_bases ,
115
- 'darwin' : ['/usr/local/' , '/usr' , '/usr/X11' ,
116
- '/opt/X11' , '/opt/local' ],
117
- 'sunos5' : [os .getenv ('MPLIB_BASE' ) or '/usr/local' , ],
118
- 'gnu0' : ['/usr' ],
119
- 'aix5' : ['/usr/local' ],
120
- }
121
- return basedir_map .get (sys .platform , ['/usr/local' , '/usr' ])
122
-
123
-
124
- def get_include_dirs ():
125
- """
126
- Returns a list of standard include directories on this platform.
127
- """
128
- include_dirs = [os .path .join (d , 'include' ) for d in get_base_dirs ()]
129
- if sys .platform != 'win32' :
130
- # gcc includes these dirs automatically, so also look for headers in
131
- # these dirs
132
- include_dirs .extend (
133
- os .environ .get ('CPATH' , '' ).split (os .pathsep ))
134
- include_dirs .extend (
135
- os .environ .get ('CPLUS_INCLUDE_PATH' , '' ).split (os .pathsep ))
136
- return include_dirs
137
-
138
-
139
87
def is_min_version (found , minversion ):
140
88
"""
141
89
Returns whether *found* is a version at least as high as *minversion*.
@@ -169,32 +117,6 @@ def print_line(*args, **kwargs):
169
117
print_status = print_message = print_raw = print_line
170
118
171
119
172
- def make_extension (name , files , * args , ** kwargs ):
173
- """
174
- Make a new extension. Automatically sets include_dirs and
175
- library_dirs to the base directories appropriate for this
176
- platform.
177
-
178
- `name` is the name of the extension.
179
-
180
- `files` is a list of source files.
181
-
182
- Any additional arguments are passed to the
183
- `distutils.core.Extension` constructor.
184
- """
185
- ext = Extension (name , files , * args , ** kwargs )
186
- for dir in get_base_dirs ():
187
- include_dir = os .path .join (dir , 'include' )
188
- if os .path .exists (include_dir ):
189
- ext .include_dirs .append (include_dir )
190
- for lib in ('lib' , 'lib64' ):
191
- lib_dir = os .path .join (dir , lib )
192
- if os .path .exists (lib_dir ):
193
- ext .library_dirs .append (lib_dir )
194
- ext .include_dirs .append ('.' )
195
- return ext
196
-
197
-
198
120
def get_file_hash (filename ):
199
121
"""
200
122
Get the SHA256 hash of a given filename.
@@ -242,8 +164,10 @@ def set_pkgconfig_path(self):
242
164
def setup_extension (self , ext , package ,
243
165
alt_exec = None , default_libraries = ()):
244
166
"""Add parameters to the given *ext* for the given *package*."""
245
- cmd = ([self .pkg_config , package ] if self .pkg_config
246
- else alt_exec )
167
+
168
+ # First, try to get the flags from pkg-config.
169
+
170
+ cmd = ([self .pkg_config , package ] if self .pkg_config else alt_exec )
247
171
if cmd is not None :
248
172
try :
249
173
flags = shlex .split (subprocess .check_output (
@@ -259,7 +183,21 @@ def setup_extension(self, ext, package,
259
183
ext .extra_compile_args .extend (flags )
260
184
ext .extra_link_args .extend (flags )
261
185
return
262
- # Else, fall back on the defaults.
186
+
187
+ # If that fails, fall back on the defaults.
188
+
189
+ # conda Windows header and library paths.
190
+ # https://github.com/conda/conda/issues/2312 re: getting the env dir.
191
+ if sys .platform == 'win32' :
192
+ conda_env_path = (os .getenv ('CONDA_PREFIX' ) # conda >= 4.1
193
+ or os .getenv ('CONDA_DEFAULT_ENV' )) # conda < 4.1
194
+ if conda_env_path and os .path .isdir (conda_env_path ):
195
+ ext .include_dirs .append (os .fspath (
196
+ pathlib .Path (conda_env_path , "Library/include" )))
197
+ ext .library_dirs .append (os .fspath (
198
+ pathlib .Path (conda_env_path , "Library/lib" )))
199
+
200
+ # Default linked libs.
263
201
ext .libraries .extend (default_libraries )
264
202
265
203
def get_version (self , package ):
@@ -834,7 +772,7 @@ def get_extension(self):
834
772
'src/mplutils.cpp' ,
835
773
'src/py_converters.cpp' ,
836
774
]
837
- ext = make_extension ('matplotlib.ft2font' , sources )
775
+ ext = Extension ('matplotlib.ft2font' , sources )
838
776
FreeType ().add_flags (ext )
839
777
Numpy ().add_flags (ext )
840
778
LibAgg ().add_flags (ext , add_sources = False )
@@ -858,7 +796,7 @@ def get_extension(self):
858
796
'src/_png.cpp' ,
859
797
'src/mplutils.cpp' ,
860
798
]
861
- ext = make_extension ('matplotlib._png' , sources )
799
+ ext = Extension ('matplotlib._png' , sources )
862
800
pkg_config .setup_extension (
863
801
ext , 'libpng' ,
864
802
alt_exec = ['libpng-config' , '--cflags' , '--ldflags' ],
@@ -890,7 +828,7 @@ def get_extension(self):
890
828
'extern/ttconv/pprdrv_tt2.cpp' ,
891
829
'extern/ttconv/ttutil.cpp'
892
830
]
893
- ext = make_extension ('matplotlib.ttconv' , sources )
831
+ ext = Extension ('matplotlib.ttconv' , sources )
894
832
Numpy ().add_flags (ext )
895
833
ext .include_dirs .insert (0 , 'extern' )
896
834
return ext
@@ -905,7 +843,7 @@ def get_extension(self):
905
843
'src/_path_wrapper.cpp'
906
844
]
907
845
908
- ext = make_extension ('matplotlib._path' , sources )
846
+ ext = Extension ('matplotlib._path' , sources )
909
847
Numpy ().add_flags (ext )
910
848
LibAgg ().add_flags (ext )
911
849
return ext
@@ -921,7 +859,7 @@ def get_extension(self):
921
859
'src/_image_wrapper.cpp' ,
922
860
'src/py_converters.cpp'
923
861
]
924
- ext = make_extension ('matplotlib._image' , sources )
862
+ ext = Extension ('matplotlib._image' , sources )
925
863
Numpy ().add_flags (ext )
926
864
LibAgg ().add_flags (ext )
927
865
@@ -937,7 +875,7 @@ def get_extension(self):
937
875
"src/_contour_wrapper.cpp" ,
938
876
'src/py_converters.cpp' ,
939
877
]
940
- ext = make_extension ('matplotlib._contour' , sources )
878
+ ext = Extension ('matplotlib._contour' , sources )
941
879
Numpy ().add_flags (ext )
942
880
LibAgg ().add_flags (ext , add_sources = False )
943
881
return ext
@@ -948,8 +886,8 @@ class QhullWrap(SetupPackage):
948
886
949
887
def get_extension (self ):
950
888
sources = ['src/qhull_wrap.c' ]
951
- ext = make_extension ('matplotlib._qhull' , sources ,
952
- define_macros = [('MPL_DEVNULL' , os .devnull )])
889
+ ext = Extension ('matplotlib._qhull' , sources ,
890
+ define_macros = [('MPL_DEVNULL' , os .devnull )])
953
891
Numpy ().add_flags (ext )
954
892
Qhull ().add_flags (ext )
955
893
return ext
@@ -964,7 +902,7 @@ def get_extension(self):
964
902
"src/tri/_tri_wrapper.cpp" ,
965
903
"src/mplutils.cpp"
966
904
]
967
- ext = make_extension ('matplotlib._tri' , sources )
905
+ ext = Extension ('matplotlib._tri' , sources )
968
906
Numpy ().add_flags (ext )
969
907
return ext
970
908
@@ -995,7 +933,7 @@ def get_extension(self):
995
933
"src/_backend_agg.cpp" ,
996
934
"src/_backend_agg_wrapper.cpp"
997
935
]
998
- ext = make_extension ('matplotlib.backends._backend_agg' , sources )
936
+ ext = Extension ('matplotlib.backends._backend_agg' , sources )
999
937
Numpy ().add_flags (ext )
1000
938
LibAgg ().add_flags (ext )
1001
939
FreeType ().add_flags (ext )
@@ -1015,7 +953,7 @@ def get_extension(self):
1015
953
'src/py_converters.cpp' ,
1016
954
]
1017
955
1018
- ext = make_extension ('matplotlib.backends._tkagg' , sources )
956
+ ext = Extension ('matplotlib.backends._tkagg' , sources )
1019
957
self .add_flags (ext )
1020
958
Numpy ().add_flags (ext )
1021
959
LibAgg ().add_flags (ext , add_sources = False )
@@ -1044,7 +982,7 @@ def get_extension(self):
1044
982
'src/_macosx.m'
1045
983
]
1046
984
1047
- ext = make_extension ('matplotlib.backends._macosx' , sources )
985
+ ext = Extension ('matplotlib.backends._macosx' , sources )
1048
986
ext .extra_link_args .extend (['-framework' , 'Cocoa' ])
1049
987
if platform .python_implementation ().lower () == 'pypy' :
1050
988
ext .extra_compile_args .append ('-DPYPY=1' )
@@ -1069,7 +1007,7 @@ def get_extension(self):
1069
1007
sources = [
1070
1008
"src/_windowing.cpp"
1071
1009
]
1072
- ext = make_extension ('matplotlib._windowing' , sources )
1010
+ ext = Extension ('matplotlib._windowing' , sources )
1073
1011
ext .include_dirs .extend (['C:/include' ])
1074
1012
ext .libraries .extend (['user32' ])
1075
1013
ext .library_dirs .extend (['C:/lib' ])
0 commit comments