From 3d3722b4dacd8e51475c61c0f1bf1eca3c30934f Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 8 Apr 2013 12:18:19 -0400 Subject: [PATCH] Fixes #1884 -- Don't require a PyCXX.pc file (since it doesn't exist upstream and in many packages). Don't overwrite existing libraries on an extension if pkg-config fails for one component. Don't spew pkg-config error messages to the console. --- setupext.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/setupext.py b/setupext.py index 63109aed297b..c8a6e5dce89a 100644 --- a/setupext.py +++ b/setupext.py @@ -281,7 +281,8 @@ def setup_extension(self, ext, package, default_include_dirs=[], use_defaults = True if self.has_pkgconfig: try: - output = check_output(command, shell=True) + output = check_output(command, shell=True, + stderr=subprocess.STDOUT) except subprocess.CalledProcessError: pass else: @@ -303,7 +304,7 @@ def setup_extension(self, ext, package, default_include_dirs=[], dir = os.path.join(base, lib) if os.path.exists(dir): ext.library_dirs.append(dir) - ext.libraries = default_libraries + ext.libraries.extend(default_libraries) return True return False @@ -321,6 +322,7 @@ def get_version(self, package): return output return None + # The PkgConfig class should be used through this singleton pkg_config = PkgConfig() @@ -402,13 +404,17 @@ def _check_for_pkg_config(self, package, include_file, min_version=None, if version is None: version = pkg_config.get_version(package) + if version is None: + raise CheckFailed( + "pkg-config information for '%s' could not be found" % + package) + if min_version == 'PATCH': raise CheckFailed( "Requires patches that have not been merged upstream.") if min_version: - if (version is not None and - not is_min_version(version, min_version)): + if (not is_min_version(version, min_version)): raise CheckFailed( "Requires %s %s or later. Found %s." % (package, min_version, version)) @@ -665,8 +671,17 @@ def check(self): return self._check_for_pkg_config( 'PyCXX', 'CXX/Extensions.hxx', min_version='6.2.4') except CheckFailed as e: - self.__class__.found_external = False - return str(e) + ' Using local copy.' + # Since there is no .pc file for PyCXX upstream, many + # distros don't package it either. We don't necessarily + # need to fall back to a local build in that scenario if + # the header files can be found. + base_include_dirs = [ + os.path.join(x, 'include') for x in get_base_dirs()] + if has_include_file(base_include_dirs, 'CXX/Extensions.hxx'): + return 'Using system CXX (version unknown, no pkg-config info)' + else: + self.__class__.found_external = False + return str(e) + ' Using local copy.' def add_flags(self, ext): if self.found_external: