Skip to content
Snippets Groups Projects
Commit c60c3d98 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Scan pkg-config location before using it to avoid impromptu error message

parent 894bd61a
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ import os ...@@ -7,7 +7,7 @@ import os
import sys import sys
import subprocess import subprocess
import logging import logging
from .utils import uniq, uniq_paths from .utils import uniq, uniq_paths, find_executable
def call_pkgconfig(cmd, paths=None): def call_pkgconfig(cmd, paths=None):
"""Runs a command as a subprocess and raises if that does not work """Runs a command as a subprocess and raises if that does not work
...@@ -15,6 +15,11 @@ def call_pkgconfig(cmd, paths=None): ...@@ -15,6 +15,11 @@ def call_pkgconfig(cmd, paths=None):
Returns the exit status, stdout and stderr. Returns the exit status, stdout and stderr.
""" """
# locates the pkg-config program
pkg_config = find_executable('pkg-config')
if not pkg_config:
raise OSError("Cannot find `pkg-config' - did you install it?")
# sets the PKG_CONFIG_PATH taking into consideration: # sets the PKG_CONFIG_PATH taking into consideration:
# 1. BOB_PREFIX_PATH, if set # 1. BOB_PREFIX_PATH, if set
# 2. the paths set by the user # 2. the paths set by the user
...@@ -43,7 +48,7 @@ def call_pkgconfig(cmd, paths=None): ...@@ -43,7 +48,7 @@ def call_pkgconfig(cmd, paths=None):
env['PKG_CONFIG_PATH'] = os.pathsep.join([var, old]) if old else var env['PKG_CONFIG_PATH'] = os.pathsep.join([var, old]) if old else var
# calls the program # calls the program
cmd = ['pkg-config'] + [str(k) for k in cmd] cmd = pkg_config[:1] + [str(k) for k in cmd]
subproc = subprocess.Popen( subproc = subprocess.Popen(
cmd, cmd,
env=env, env=env,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment