From cba189e783f88e6ef15ccaaedd4daad255e56712 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 19 May 2016 12:29:40 +0200 Subject: [PATCH] build: unbreak configure with python 2.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 2b1c01c2c ("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: https://github.com/nodejs/node/issues/6711 PR-URL: https://github.com/nodejs/node/pull/6874 Reviewed-By: Johan Bergström Reviewed-By: Robert Jefe Lindstaedt Reviewed-By: Sakthipriyan Vairamani --- configure | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/configure b/configure index 4434d53e47bb10..0be3a52bf7e886 100755 --- a/configure +++ b/configure @@ -1,4 +1,6 @@ #!/usr/bin/env python + +import errno import optparse import os import pprint @@ -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