Skip to content

Commit

Permalink
Make build process set PKG_CONFIG_PATH variable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dmcdougall committed Oct 2, 2012
1 parent 98e7a95 commit 101beb9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ def get_win32_compiler():
else:
std_libs = ['stdc++', 'm']

def set_pkgconfig_path():
pkgconfig_path = sysconfig.get_config_var('LIBDIR')
if pkgconfig_path is None:
return

pkgconfig_path += '/pkgconfig'
if not os.path.isdir(pkgconfig_path):
return

try:
os.environ['PKG_CONFIG_PATH'] += ':' + pkgconfig_path
except KeyError:
os.environ['PKG_CONFIG_PATH'] = pkgconfig_path

def has_pkgconfig():
if has_pkgconfig.cache is not None:
return has_pkgconfig.cache
Expand All @@ -267,6 +281,10 @@ def has_pkgconfig():
#print 'environ', os.environ['PKG_CONFIG_PATH']
status, output = getstatusoutput("pkg-config --help")
has_pkgconfig.cache = (status == 0)

# Set the PKG_CONFIG_PATH environment variable
if has_pkgconfig.cache:
set_pkgconfig_path()
return has_pkgconfig.cache
has_pkgconfig.cache = None

Expand Down

0 comments on commit 101beb9

Please sign in to comment.