Skip to content

Commit 230be81

Browse files
committed
tools: use py2.6 equivalent of check_output
Python 2.6 does not have `subprocess.check_output`, as it was introduced only in Python 2.7. This patch uses `subprocess.Popen` to get the data written to stdout by the `pkg-config` program. Fixes: nodejs#6711
1 parent 0e2b250 commit 230be81

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

configure

+10-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
@@ -439,16 +441,14 @@ def pkg_config(pkg):
439441
retval = ()
440442
for flag in ['--libs-only-l', '--cflags-only-I', '--libs-only-L']:
441443
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)
451-
retval += (val,)
444+
stdout = subprocess.Popen(shlex.split(pkg_config) + [args, flag, pkg],
445+
stdout=subprocess.PIPE).communicate()[0].strip()
446+
except OSError as e:
447+
if e.errno == errno.ENONET:
448+
# no pkg-config/pkgconf installed
449+
return (None, None, None)
450+
raise e
451+
retval += (stdout,)
452452
return retval
453453

454454

0 commit comments

Comments
 (0)