Handle more than one directory returned by pkg-config.

tiff (4.5.0-1) in Debian results in two include directories being returned:
```
-I/usr/include/x86_64-linux-gnu -I/usr/include
```
This commit is contained in:
Bas Couwenberg 2023-01-14 19:09:43 +01:00
parent 43bb03539e
commit 04cf5e2cfc

View File

@ -263,18 +263,20 @@ def _pkg_config(name):
if not DEBUG: if not DEBUG:
command_libs.append("--silence-errors") command_libs.append("--silence-errors")
command_cflags.append("--silence-errors") command_cflags.append("--silence-errors")
libs = ( libs = re.split(
r"\s*-L",
subprocess.check_output(command_libs, stderr=stderr) subprocess.check_output(command_libs, stderr=stderr)
.decode("utf8") .decode("utf8")
.strip() .strip(),
.replace("-L", "")
) )
cflags = ( libs.remove("")
subprocess.check_output(command_cflags) cflags = re.split(
r"\s*-I",
subprocess.check_output(command_cflags, stderr=stderr)
.decode("utf8") .decode("utf8")
.strip() .strip(),
.replace("-I", "")
) )
cflags.remove("")
return libs, cflags return libs, cflags
except Exception: except Exception:
pass pass
@ -473,8 +475,12 @@ class pil_build_ext(build_ext):
else: else:
lib_root = include_root = root lib_root = include_root = root
_add_directory(library_dirs, lib_root) if lib_root is not None:
_add_directory(include_dirs, include_root) for lib_dir in lib_root:
_add_directory(library_dirs, lib_dir)
if include_root is not None:
for include_dir in include_root:
_add_directory(include_dirs, include_dir)
# respect CFLAGS/CPPFLAGS/LDFLAGS # respect CFLAGS/CPPFLAGS/LDFLAGS
for k in ("CFLAGS", "CPPFLAGS", "LDFLAGS"): for k in ("CFLAGS", "CPPFLAGS", "LDFLAGS"):