Skip to content

Commit 65b75b5

Browse files
bnoordhuisMyles Borins
authored and
Myles Borins
committed
build: unbreak configure with python 2.6
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]>
1 parent 140b84d commit 65b75b5

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

configure

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env python
2+
3+
import errno
24
import optparse
35
import os
46
import pprint
@@ -400,19 +402,16 @@ def b(value):
400402

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

0 commit comments

Comments
 (0)