From 5836c98f06c4731f864e4e644e633ed23487e277 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 15 May 2015 03:43:17 -0400 Subject: [PATCH 1/2] setupext: do not mess with PKG_CONFIG_PATH The current code always sets PKG_CONFIG_PATH to build paths in / which breaks cross-compiling -- things like /usr/lib are for the build system (e.g. x86) and not for the target (e.g. arm). Since we're adding paths that are already the default for pkg-config, there's no point in trying to be smart here. Just punt the code. This basically reverts commit 101beb975d3a1218350f02bf68dc2a43ac8ff148. --- setupext.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/setupext.py b/setupext.py index 6d363012eb4e..52fe915f32fb 100644 --- a/setupext.py +++ b/setupext.py @@ -270,27 +270,12 @@ def __init__(self): self.has_pkgconfig = False else: self.pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config') - self.set_pkgconfig_path() self.has_pkgconfig = shutil.which(self.pkg_config) is not None if not self.has_pkgconfig: print("IMPORTANT WARNING:\n" " pkg-config is not installed.\n" " matplotlib may not be able to find some of its dependencies") - def set_pkgconfig_path(self): - pkgconfig_path = sysconfig.get_config_var('LIBDIR') - if pkgconfig_path is None: - return - - pkgconfig_path = os.path.join(pkgconfig_path, 'pkgconfig') - if not os.path.isdir(pkgconfig_path): - return - - try: - os.environ['PKG_CONFIG_PATH'] += ':' + pkgconfig_path - except KeyError: - os.environ['PKG_CONFIG_PATH'] = pkgconfig_path - def setup_extension(self, ext, package, default_include_dirs=[], default_library_dirs=[], default_libraries=[], alt_exec=None): From cd06e1b0421bf5561e5c5fa7fdb2a82d8d935afb Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 15 May 2015 03:49:02 -0400 Subject: [PATCH 2/2] setupext: do not hardcode system -I/-L paths when pkg-config is available If we have pkg-config, then there's no need to hardcode the system -I/-L paths as the pkg-config files will give us all the info we need. --- setupext.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/setupext.py b/setupext.py index 52fe915f32fb..5ba3bcd47822 100644 --- a/setupext.py +++ b/setupext.py @@ -221,7 +221,7 @@ def make_extension(name, files, *args, **kwargs): """ Make a new extension. Automatically sets include_dirs and library_dirs to the base directories appropriate for this - platform. + platform when pkg-config is not available. `name` is the name of the extension. @@ -231,14 +231,15 @@ def make_extension(name, files, *args, **kwargs): `distutils.core.Extension` constructor. """ ext = DelayedExtension(name, files, *args, **kwargs) - for dir in get_base_dirs(): - include_dir = os.path.join(dir, 'include') - if os.path.exists(include_dir): - ext.include_dirs.append(include_dir) - for lib in ('lib', 'lib64'): - lib_dir = os.path.join(dir, lib) - if os.path.exists(lib_dir): - ext.library_dirs.append(lib_dir) + if not pkg_config.has_pkgconfig: + for dir in get_base_dirs(): + include_dir = os.path.join(dir, 'include') + if os.path.exists(include_dir): + ext.include_dirs.append(include_dir) + for lib in ('lib', 'lib64'): + lib_dir = os.path.join(dir, lib) + if os.path.exists(lib_dir): + ext.library_dirs.append(lib_dir) ext.include_dirs.append('.') return ext