diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-12-14 22:46:10 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-12-14 22:52:47 -0500 |
commit | 930bf897969cf7a98b845bef60653cdf2edc4355 (patch) | |
tree | fda837b6326cdf7c2bf52af8bc0adb0d7b55f97b | |
parent | b4cfd41a06bfd4133d9359731eb637e221d179bf (diff) | |
download | python-systemd-930bf897969cf7a98b845bef60653cdf2edc4355.tar.gz |
setup.py: allow LIBSYSTEMD_VERSION to be overridden
This is useful when testing against old or unreleases versions of
the library:
make PYTHON=python3 INCLUDE_DIR=/home/zbyszek/src/systemd-master/src LIBSYSTEMD_VERSION=233
-rw-r--r-- | setup.py | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -12,6 +12,7 @@ def call(*cmd): return cmd.returncode, cmd.stderr.read() def pkgconfig(package, **kw): + pkg_version = package.replace('-', '_').upper() + '_VERSION' flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'} pkgconf = os.getenv('PKG_CONFIG', 'pkg-config') status, result = call(pkgconf, '--libs', '--cflags', package) @@ -19,9 +20,13 @@ def pkgconfig(package, **kw): return status, result for token in result.split(): kw.setdefault(flag_map.get(token[:2]), []).append(token[2:]) - version = check_output([pkgconf, '--modversion', package], - universal_newlines=True).strip() - pair = (package.replace('-', '_').upper() + '_VERSION', version) + + # allow version detection to be overriden using environment variables + version = os.getenv(pkg_version) + if not version: + version = check_output([pkgconf, '--modversion', package], + universal_newlines=True).strip() + pair = (pkg_version, version) defines = kw.setdefault('define_macros', []) if pair not in defines: defines.append(pair) |