summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-09-04 17:05:08 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-09-04 17:16:28 +0200
commitf83dea9f8d74da509befb9d1cca269ab1686ab1a (patch)
tree633f1754db02caddc3d75107869d9001fcdec1d8 /setup.py
parentc71fbb58e52e93e5aa1b18257a7a236d22f9a594 (diff)
downloadpython-systemd-f83dea9f8d74da509befb9d1cca269ab1686ab1a.tar.gz
Add compatibility with systemd < 205
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/setup.py b/setup.py
index cb4de74..36db2ef 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
import sys, os
from distutils.core import setup, Extension
-from subprocess import Popen, PIPE
+from subprocess import Popen, PIPE, check_output
def call(*cmd):
cmd = Popen(cmd,
@@ -18,14 +18,20 @@ 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(['pkg-config', '--modversion', package],
+ universal_newlines=True).strip()
+ pair = (package.replace('-', '_').upper() + '_VERSION', version)
+ defines = kw.setdefault('define_macros', [])
+ if pair not in defines:
+ defines.append(pair)
return status, kw
-def lib(*names):
+def lib(*names, **kw):
if '--version' in sys.argv:
return {}
results = []
for name in names:
- status, result = pkgconfig(name)
+ status, result = pkgconfig(name, **kw)
if status == 0:
return result
results.append(result)
@@ -34,35 +40,30 @@ def lib(*names):
sys.exit(status)
version = '230'
-defines = [('PACKAGE_VERSION', '"{}"'.format(version))]
+defines = {'define_macros':[('PACKAGE_VERSION', '"{}"'.format(version))]}
_journal = Extension('systemd/_journal',
- define_macros = defines,
sources = ['systemd/_journal.c',
'systemd/pyutil.c'],
- **lib('libsystemd', 'libsystemd-journal'))
+ **lib('libsystemd', 'libsystemd-journal', **defines))
_reader = Extension('systemd/_reader',
- define_macros = defines,
sources = ['systemd/_reader.c',
'systemd/pyutil.c',
'systemd/strv.c'],
- **lib('libsystemd', 'libsystemd-journal'))
+ **lib('libsystemd', 'libsystemd-journal', **defines))
_daemon = Extension('systemd/_daemon',
- define_macros = defines,
sources = ['systemd/_daemon.c',
'systemd/pyutil.c'],
- **lib('libsystemd', 'libsystemd-daemon'))
+ **lib('libsystemd', 'libsystemd-daemon', **defines))
id128 = Extension('systemd/id128',
- define_macros = defines,
sources = ['systemd/id128.c',
'systemd/pyutil.c'],
- **lib('libsystemd', 'libsystemd-id128'))
+ **lib('libsystemd', 'libsystemd-id128', **defines))
login = Extension('systemd/login',
- define_macros = defines,
sources = ['systemd/login.c',
'systemd/pyutil.c',
'systemd/strv.c'],
- **lib('libsystemd', 'libsystemd-login'))
+ **lib('libsystemd', 'libsystemd-login', **defines))
setup (name = 'python-systemd',
version = version,
description = 'Native interface to the facilities of systemd',