Skip to content

Commit

Permalink
tools: use py2.6 equivalent of check_output
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thefourtheye committed May 12, 2016
1 parent 0e2b250 commit 230be81
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 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 @@ -439,16 +441,14 @@ def pkg_config(pkg):
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)
retval += (val,)
stdout = subprocess.Popen(shlex.split(pkg_config) + [args, flag, pkg],
stdout=subprocess.PIPE).communicate()[0].strip()
except OSError as e:
if e.errno == errno.ENONET:
# no pkg-config/pkgconf installed
return (None, None, None)
raise e
retval += (stdout,)
return retval


Expand Down

0 comments on commit 230be81

Please sign in to comment.