Skip to content

Commit

Permalink
Merge pull request #6138 from jameshilliard/fix-pkg-config
Browse files Browse the repository at this point in the history
Search pkgconf system libs/cflags
  • Loading branch information
radarhere committed May 2, 2022
2 parents dac49dc + 6ec9dfb commit 0a30e43
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions setup.py
Expand Up @@ -250,28 +250,32 @@ def _cmd_exists(cmd):


def _pkg_config(name):
try:
command = os.environ.get("PKG_CONFIG", "pkg-config")
command_libs = [command, "--libs-only-L", name]
command_cflags = [command, "--cflags-only-I", name]
if not DEBUG:
command_libs.append("--silence-errors")
command_cflags.append("--silence-errors")
libs = (
subprocess.check_output(command_libs)
.decode("utf8")
.strip()
.replace("-L", "")
)
cflags = (
subprocess.check_output(command_cflags)
.decode("utf8")
.strip()
.replace("-I", "")
)
return libs, cflags
except Exception:
pass
command = os.environ.get("PKG_CONFIG", "pkg-config")
for keep_system in (True, False):
try:
command_libs = [command, "--libs-only-L", name]
command_cflags = [command, "--cflags-only-I", name]
if keep_system:
command_libs.append("--keep-system-libs")
command_cflags.append("--keep-system-cflags")
if not DEBUG:
command_libs.append("--silence-errors")
command_cflags.append("--silence-errors")
libs = (
subprocess.check_output(command_libs)
.decode("utf8")
.strip()
.replace("-L", "")
)
cflags = (
subprocess.check_output(command_cflags)
.decode("utf8")
.strip()
.replace("-I", "")
)
return libs, cflags
except Exception:
pass


class pil_build_ext(build_ext):
Expand Down

0 comments on commit 0a30e43

Please sign in to comment.