Skip to content

Commit 62376d9

Browse files
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: nodejs#6711 PR-URL: nodejs#6874 Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Robert Jefe Lindstaedt <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent b6a646d commit 62376d9

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
@@ -435,19 +437,16 @@ def b(value):
435437

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

0 commit comments

Comments
 (0)