Skip to content

Commit

Permalink
build: unbreak configure with python 2.6
Browse files Browse the repository at this point in the history
Commit 2b1c01c ("build: refactor pkg-config for shared libraries")
from May 2015 introduced python 2.7-specific code.

It mainly affects people building on old RHEL platforms where the system
python is 2.6.  Seemingly a dying breed because the issue went unnoticed
(or at least unreported) for a whole year.

Fixes: #6711
PR-URL: #6874
Reviewed-By: Johan Bergström <[email protected]>
Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
bnoordhuis authored and Myles Borins committed Jul 11, 2016
1 parent ef8a44d commit eb293c3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python

import errno
import optparse
import os
import pprint
Expand Down Expand Up @@ -400,19 +402,16 @@ def b(value):

def pkg_config(pkg):
pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config')
args = '--silence-errors'
retval = ()
for flag in ['--libs-only-l', '--cflags-only-I', '--libs-only-L']:
try:
val = subprocess.check_output([pkg_config, args, flag, pkg])
# check_output returns bytes
val = val.encode().strip().rstrip('\n')
except subprocess.CalledProcessError:
# most likely missing a .pc-file
val = None
except OSError:
# no pkg-config/pkgconf installed
return (None, None, None)
proc = subprocess.Popen(
shlex.split(pkg_config) + ['--silence-errors', flag, pkg],
stdout=subprocess.PIPE)
val = proc.communicate()[0].strip()
except OSError, e:
if e.errno != errno.ENOENT: raise e # Unexpected error.
return (None, None, None) # No pkg-config/pkgconf installed.
retval += (val,)
return retval

Expand Down

0 comments on commit eb293c3

Please sign in to comment.