Skip to content

Commit 101beb9

Browse files
committed
Make build process set PKG_CONFIG_PATH variable
If the platform has pkg-config then add python's .pc files to the end of the pkg-config search path. If there was a problem setting it or pkg-config doesn't exist then do nothing. It appears that the environment variable change only exists within the build process.
1 parent 98e7a95 commit 101beb9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

setupext.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,20 @@ def get_win32_compiler():
258258
else:
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 += '/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+
261275
def 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
271289
has_pkgconfig.cache = None
272290

0 commit comments

Comments
 (0)