diff options
| author | Jeroen Dekkers <jeroen@dekkers.ch> | 2015-10-15 15:27:57 +0200 |
|---|---|---|
| committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-10-25 11:55:48 -0400 |
| commit | 718cefefcdcbd916bcd24f9d2d8f0d927cbc6342 (patch) | |
| tree | 5056281a9a55fc3d14c28491750d42d50192e3af /setup.py | |
| parent | b71b8b64ebb28ddbf1130e9127f1e9fc5fb6117f (diff) | |
| download | python-systemd-718cefefcdcbd916bcd24f9d2d8f0d927cbc6342.tar.gz | |
build-sys: generate systemd/id128-constants.h in setup.py
Fixes #7.
Diffstat (limited to 'setup.py')
| -rw-r--r-- | setup.py | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -1,7 +1,25 @@ import sys, os from distutils.core import setup, Extension +from distutils.command.build_ext import build_ext from subprocess import Popen, PIPE, check_output + +class build_ext_generate_id128_header(build_ext): + def run(self): + if not self.dry_run and not os.path.exists("systemd/id128-constants.h"): + constants = [] + with open("/usr/include/systemd/sd-messages.h") as f: + for line in f: + if line.startswith('#define SD'): + constants.append(line.split()[1]) + + with open("systemd/id128-constants.h", "w") as f: + for c in constants: + f.write('add_id(m, "{0}", {0}) JOINER\n'.format(c)) + + return build_ext.run(self) + + def call(*cmd): cmd = Popen(cmd, stdout=PIPE, stderr=PIPE, @@ -84,4 +102,5 @@ setup (name = 'python-systemd', _reader, _daemon, id128, - login]) + login], + cmdclass = {'build_ext': build_ext_generate_id128_header}) |
