5757basedir = defaultdict (lambda : ['/usr/local' , '/usr' ], {
5858 # execptions to the ['/usr/local', '/usr'] defaults
5959 'win32' : ['win32_static' ,],
60- 'darwin' : ['/usr/local/' , '/usr' , '/usr/X11' ],
60+ 'darwin' : ['/usr/local/' , '/usr' , '/usr/X11' , '/opt/local' ],
6161 'sunos5' : [os .getenv ('MPLIB_BASE' ) or '/usr/local' ,],
6262 'gnu0' : ['/usr' ],
6363 'aix5' : ['/usr/local' ],
@@ -258,6 +258,20 @@ def get_win32_compiler():
258258else :
259259 std_libs = ['stdc++' , 'm' ]
260260
261+ def set_pkgconfig_path ():
262+ pkgconfig_path = sysconfig .get_config_var ('LIBDIR' )
263+ if pkgconfig_path is None :
264+ return
265+
266+ pkgconfig_path = os .path .join (pkgconfig_path , 'pkgconfig' )
267+ if not os .path .isdir (pkgconfig_path ):
268+ return
269+
270+ try :
271+ os .environ ['PKG_CONFIG_PATH' ] += ':' + pkgconfig_path
272+ except KeyError :
273+ os .environ ['PKG_CONFIG_PATH' ] = pkgconfig_path
274+
261275def has_pkgconfig ():
262276 if has_pkgconfig .cache is not None :
263277 return has_pkgconfig .cache
@@ -267,6 +281,10 @@ def has_pkgconfig():
267281 #print 'environ', os.environ['PKG_CONFIG_PATH']
268282 status , output = getstatusoutput ("pkg-config --help" )
269283 has_pkgconfig .cache = (status == 0 )
284+
285+ # Set the PKG_CONFIG_PATH environment variable
286+ if has_pkgconfig .cache :
287+ set_pkgconfig_path ()
270288 return has_pkgconfig .cache
271289has_pkgconfig .cache = None
272290
0 commit comments