Commits

Alexander Schremmer committed 8030f30

Added RPyC support code and the necessary proxy modules to run PyQt4 applications on PyPy.

Comments (0)

Files changed (3)

pypy/lib/PyQt4.py

+from _rpyc_support import proxy_sub_module, remote_eval
+
+
+for name in ("QtCore", "QtGui", "QtWebKit"):
+    proxy_sub_module(globals(), name)
+
+s = "__import__('PyQt4').QtGui.QDialogButtonBox."
+QtGui.QDialogButtonBox.Cancel = remote_eval("%sCancel | %sCancel" % (s, s))
+QtGui.QDialogButtonBox.Ok = remote_eval("%sOk | %sOk" % (s, s))

pypy/lib/_rpyc_support.py

+import sys
+import socket
+
+from rpyc import connect, SlaveService
+from rpyc.utils.classic import DEFAULT_SERVER_PORT
+
+try:
+    conn = connect("localhost", DEFAULT_SERVER_PORT, SlaveService,
+           config=dict(call_by_value_for_builtin_mutable_types=True))
+except socket.error, e:
+    raise ImportError("Error while connecting: " + str(e))
+
+
+remote_eval = conn.eval
+
+
+def proxy_module(globals):
+    module = getattr(conn.modules, globals["__name__"])
+    for name in module.__dict__.keys():
+        globals[name] = getattr(module, name)
+
+def proxy_sub_module(globals, name):
+    fullname = globals["__name__"] + "." + name
+    sys.modules[fullname] = globals[name] = conn.modules[fullname]
+from _rpyc_support import proxy_module
+
+proxy_module(globals())
+del proxy_module