Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d3722b

Browse files
committed
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.
1 parent 6cda361 commit 3d3722b

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

setupext.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ def setup_extension(self, ext, package, default_include_dirs=[],
281281
use_defaults = True
282282
if self.has_pkgconfig:
283283
try:
284-
output = check_output(command, shell=True)
284+
output = check_output(command, shell=True,
285+
stderr=subprocess.STDOUT)
285286
except subprocess.CalledProcessError:
286287
pass
287288
else:
@@ -303,7 +304,7 @@ def setup_extension(self, ext, package, default_include_dirs=[],
303304
dir = os.path.join(base, lib)
304305
if os.path.exists(dir):
305306
ext.library_dirs.append(dir)
306-
ext.libraries = default_libraries
307+
ext.libraries.extend(default_libraries)
307308
return True
308309

309310
return False
@@ -321,6 +322,7 @@ def get_version(self, package):
321322
return output
322323
return None
323324

325+
324326
# The PkgConfig class should be used through this singleton
325327
pkg_config = PkgConfig()
326328

@@ -402,13 +404,17 @@ def _check_for_pkg_config(self, package, include_file, min_version=None,
402404
if version is None:
403405
version = pkg_config.get_version(package)
404406

407+
if version is None:
408+
raise CheckFailed(
409+
"pkg-config information for '%s' could not be found" %
410+
package)
411+
405412
if min_version == 'PATCH':
406413
raise CheckFailed(
407414
"Requires patches that have not been merged upstream.")
408415

409416
if min_version:
410-
if (version is not None and
411-
not is_min_version(version, min_version)):
417+
if (not is_min_version(version, min_version)):
412418
raise CheckFailed(
413419
"Requires %s %s or later. Found %s." %
414420
(package, min_version, version))
@@ -665,8 +671,17 @@ def check(self):
665671
return self._check_for_pkg_config(
666672
'PyCXX', 'CXX/Extensions.hxx', min_version='6.2.4')
667673
except CheckFailed as e:
668-
self.__class__.found_external = False
669-
return str(e) + ' Using local copy.'
674+
# Since there is no .pc file for PyCXX upstream, many
675+
# distros don't package it either. We don't necessarily
676+
# need to fall back to a local build in that scenario if
677+
# the header files can be found.
678+
base_include_dirs = [
679+
os.path.join(x, 'include') for x in get_base_dirs()]
680+
if has_include_file(base_include_dirs, 'CXX/Extensions.hxx'):
681+
return 'Using system CXX (version unknown, no pkg-config info)'
682+
else:
683+
self.__class__.found_external = False
684+
return str(e) + ' Using local copy.'
670685

671686
def add_flags(self, ext):
672687
if self.found_external:

0 commit comments

Comments
 (0)