commit d8e0bac0c0d831510683939ec7a7b5bd72192423 Author: Frederik Rietdijk Date: Sat Jan 5 11:38:28 2019 +0100 Have a top-level attribute for the executable diff --git a/pkgconfig/pkgconfig.py b/pkgconfig/pkgconfig.py index 3deb97f..e7c5561 100644 --- a/pkgconfig/pkgconfig.py +++ b/pkgconfig/pkgconfig.py @@ -30,6 +30,9 @@ from functools import wraps from subprocess import call, PIPE, Popen +PKG_CONFIG_EXE = "pkg-config" + + def _compare_versions(v1, v2): """ Compare two version strings and return -1, 0 or 1 depending on the equality @@ -65,7 +68,7 @@ def _convert_error(func): @_convert_error def _query(package, *options): - pkg_config_exe = os.environ.get('PKG_CONFIG', None) or 'pkg-config' + pkg_config_exe = os.environ.get('PKG_CONFIG', None) or PKG_CONFIG_EXE cmd = '{0} {1} {2}'.format(pkg_config_exe, ' '.join(options), package) proc = Popen(shlex.split(cmd), stdout=PIPE, stderr=PIPE) out, err = proc.communicate() @@ -84,7 +87,7 @@ def exists(package): If ``pkg-config`` not on path, raises ``EnvironmentError``. """ - pkg_config_exe = os.environ.get('PKG_CONFIG', None) or 'pkg-config' + pkg_config_exe = os.environ.get('PKG_CONFIG', None) or PKG_CONFIG_EXE cmd = '{0} --exists {1}'.format(pkg_config_exe, package).split() return call(cmd) == 0