@@ -288,7 +288,8 @@ def setup_extension(self, ext, package, default_include_dirs=[],
288288 command = "{0} --libs --cflags " .format (executable )
289289
290290 try :
291- output = check_output (command , shell = True )
291+ output = check_output (command , shell = True ,
292+ stderr = subprocess .STDOUT )
292293 except subprocess .CalledProcessError :
293294 pass
294295 else :
@@ -310,7 +311,7 @@ def setup_extension(self, ext, package, default_include_dirs=[],
310311 dir = os .path .join (base , lib )
311312 if os .path .exists (dir ):
312313 ext .library_dirs .append (dir )
313- ext .libraries = default_libraries
314+ ext .libraries . extend ( default_libraries )
314315 return True
315316
316317 return False
@@ -328,6 +329,7 @@ def get_version(self, package):
328329 return output
329330 return None
330331
332+
331333# The PkgConfig class should be used through this singleton
332334pkg_config = PkgConfig ()
333335
@@ -409,13 +411,17 @@ def _check_for_pkg_config(self, package, include_file, min_version=None,
409411 if version is None :
410412 version = pkg_config .get_version (package )
411413
414+ if version is None :
415+ raise CheckFailed (
416+ "pkg-config information for '%s' could not be found" %
417+ package )
418+
412419 if min_version == 'PATCH' :
413420 raise CheckFailed (
414421 "Requires patches that have not been merged upstream." )
415422
416423 if min_version :
417- if (version is not None and
418- not is_min_version (version , min_version )):
424+ if (not is_min_version (version , min_version )):
419425 raise CheckFailed (
420426 "Requires %s %s or later. Found %s." %
421427 (package , min_version , version ))
@@ -672,8 +678,17 @@ def check(self):
672678 return self ._check_for_pkg_config (
673679 'PyCXX' , 'CXX/Extensions.hxx' , min_version = '6.2.4' )
674680 except CheckFailed as e :
675- self .__class__ .found_external = False
676- return str (e ) + ' Using local copy.'
681+ # Since there is no .pc file for PyCXX upstream, many
682+ # distros don't package it either. We don't necessarily
683+ # need to fall back to a local build in that scenario if
684+ # the header files can be found.
685+ base_include_dirs = [
686+ os .path .join (x , 'include' ) for x in get_base_dirs ()]
687+ if has_include_file (base_include_dirs , 'CXX/Extensions.hxx' ):
688+ return 'Using system CXX (version unknown, no pkg-config info)'
689+ else :
690+ self .__class__ .found_external = False
691+ return str (e ) + ' Using local copy.'
677692
678693 def add_flags (self , ext ):
679694 if self .found_external :
0 commit comments