summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert McQueen <robot101@thubuntu.(none)>2006-07-12 21:53:57 +0100
committerRobert McQueen <robot101@thubuntu.(none)>2006-07-12 21:53:57 +0100
commit82a4e8afb8ca163416f602fdb1df96b11765ecb2 (patch)
tree3950f361a7eb204916788df49c6d54c656bb8ce0
parent172f80244f21a681609e6918c1f043b3272949f3 (diff)
downloaddbus-python-82a4e8afb8ca163416f602fdb1df96b11765ecb2.tar.gz
setup.py, dbus/extract.py: Patch from Osvaldo Santana Neto
<osvaldo.santana@indt.org.br> to make the python bindings build and install with distutils. Not quite working yet because of path madness with the extract.py stuff.
-rw-r--r--dbus/extract.py49
-rw-r--r--setup.py108
2 files changed, 138 insertions, 19 deletions
diff --git a/dbus/extract.py b/dbus/extract.py
index 3cdb975..28ae202 100644
--- a/dbus/extract.py
+++ b/dbus/extract.py
@@ -210,25 +210,36 @@ def do_header(filename, name=None):
print '# -- %s -- ' % filename
do_buffer(name, buffer)
-filename = sys.argv[1]
-
-if filename.endswith('.h'):
- do_header(filename)
- raise SystemExit
-
-cppflags = ""
+def main(filename, flags, output=None):
+ old_stdout = None
+ if output is not None:
+ old_stdout = sys.stdout
+ sys.stdout = output
+
+ if filename.endswith('.h'):
+ do_header(filename)
+ return
+
+ cppflags = ' '.join(flags)
+
+ fd = open(filename)
+ for line in fd:
+ match = re.match('#include [<"]([^">]+)[">]$', line)
+
+ if match:
+ filename = match.group(1)
+ print >>sys.stderr, "matched %s" % (filename)
+ command = "echo '%s'|cpp %s" % (line, cppflags)
+ output = commands.getoutput(command)
+ print >>sys.stderr, "output %s" % (output)
+ do_buffer(filename, output)
+ else:
+ print line[:-1]
+ fd.close()
-for flag in sys.argv[2:]:
- cppflags = cppflags + " " + flag
+ if old_stdout is not None:
+ sys.stdout = old_stdout
-fd = open(filename)
+if __name__ == '__main__':
+ main(sys.argv[1], sys.argv[2:])
-for line in fd.readlines():
- if line.startswith('#include'):
- filename = line.split(' ')[1][1:-2]
- command = "echo '%s'|cpp %s" % (line, cppflags)
- sys.stderr.write('running %s' % (command))
- output = commands.getoutput(command)
- do_buffer(filename, output)
- else:
- print line[:-1]
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..cb642df
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,108 @@
+import os
+import sys
+
+sys.path.append("dbus")
+
+from distutils.core import setup
+from distutils.extension import Extension
+from distutils.command.clean import clean
+from Pyrex.Distutils import build_ext
+
+import extract
+
+def remove(filename):
+ if os.path.exists(filename):
+ os.remove(filename)
+
+class full_clean(clean):
+ def run(self):
+ clean.run(self)
+ remove("dbus/extract.pyo")
+ remove("dbus/dbus_bindings.pxd")
+ remove("dbus/dbus_bindings.c")
+ remove("dbus/dbus_glib_bindings.c")
+
+includedirs_flag = ['-I.']
+dbus_includes = ['.']
+dbus_glib_includes = ['.']
+
+pipe = os.popen3("pkg-config --cflags dbus-1")
+output = pipe[1].read().strip()
+error = pipe[2].read().strip()
+for p in pipe:
+ p.close()
+if error:
+ print "ERROR: running pkg-config (%s)" % (error)
+ raise SystemExit
+includedirs_flag.extend(output.split())
+dbus_includes.extend([ x.replace("-I", "") for x in output.split() ])
+
+pipe = os.popen3("pkg-config --cflags dbus-glib-1")
+output = pipe[1].read().strip()
+error = pipe[2].read().strip()
+for p in pipe:
+ p.close()
+if error:
+ print "ERROR: running pkg-config (%s)" % (error)
+ raise SystemExit
+includedirs_flag.extend(output.split())
+dbus_glib_includes.extend([ x.replace("-I", "") for x in output.split() ])
+
+output = open("dbus/dbus_bindings.pxd", 'w')
+includedirs_flag.append('dbus')
+extract.main("dbus/dbus_bindings.pxd.in", includedirs_flag, output)
+output.close()
+
+long_desc = '''D-BUS is a message bus system, a simple way for applications to
+talk to one another.
+
+D-BUS supplies both a system daemon (for events such as "new hardware device
+added" or "printer queue changed") and a per-user-login-session daemon (for
+general IPC needs among user applications). Also, the message bus is built on
+top of a general one-to-one message passing framework, which can be used by any
+two apps to communicate directly (without going through the message bus daemon).
+Currently the communicating applications are on one computer, but TCP/IP option
+is available and remote support planned.'''
+
+setup(
+ name='dbus',
+ version='0.70',
+ description='D-Bus Python bindings',
+ long_description=long_desc,
+ url='http://dbus.freedesktop.org/',
+ author='John (J5) Palmieri',
+ author_email='johnp@redhat.com',
+ maintainer='Osvaldo Santana Neto',
+ maintainer_email='osvaldo.santana@indt.org.br',
+ package_dir={'':'dbus'},
+ py_modules=[
+ "_dbus",
+ "exceptions",
+ "glib",
+ "__init__",
+ "matchrules",
+ "service",
+ "types",
+ "decorators",
+ "introspect_parser",
+ "proxies",
+ "_util",
+ ],
+ ext_modules=[
+ Extension("dbus_bindings", ["dbus/dbus_bindings.pyx"],
+ include_dirs=dbus_includes,
+ libraries=["dbus-1"],
+
+ ),
+ Extension("dbus_glib_bindings", ["dbus/dbus_glib_bindings.pyx"],
+ include_dirs=dbus_glib_includes,
+ libraries=["dbus-glib-1", "dbus-1", "glib-2.0"],
+ define_macros=[
+ ('DBUS_API_SUBJECT_TO_CHANGE', '1')
+ ],
+ ),
+ ],
+ cmdclass={'build_ext': build_ext, 'clean': full_clean}
+)
+
+# vim:ts=4:sw=4:tw=80:si:ai:showmatch:et