Commit c1f6e12f authored by Julian Taylor's avatar Julian Taylor

build shared cffi pypy libraries and patch module loading to find it

parent e9ec6eb2
......@@ -111,7 +111,7 @@ Description: Python3 bindings for 0MQ library - debugging files
Package: pypy-zmq
Architecture: any
Depends: libzmq3-dev, pypy (>= 2.0.0), ${misc:Depends}, ${shlibs:Depends}
Depends: gcc, libzmq3-dev, pypy (>= 2.0.0), ${misc:Depends}, ${shlibs:Depends}
Description: PyPy bindings for 0MQ library
Python bindings for 0MQ. 0MQ is a small, fast, and free
software library that gives you message-passing concurrency
Description: check package root for cffi binaries
cffi checks __pycache__ for binaries which is cleaned by pypy installation so
packages can't ship in there.
Instead ship in package root and patch module finding to look in there.
--- a/zmq/cffi_core/
+++ b/zmq/cffi_core/
@@ -9,6 +9,40 @@
# the file COPYING.BSD, distributed as part of this software.
+import imp
+import os.path
+import sys
+import cffi.vengine_cpy
+import cffi.vengine_gen
+ma_triplet = None
+def vengine_gen_find_module(self, module_name, path, so_suffixes):
+ global ma_triplet
+ if ma_triplet is None:
+ try:
+ import subprocess as sp
+ p = sp.Popen(["gcc", "-print-multiarch"], stdout=sp.PIPE)
+ ma_triplet = str(p.communicate()[0].decode().strip())
+ except:
+ import warnings
+ warnings.warn('failed to detect multiarch paths, please install gcc')
+ for so_suffix in so_suffixes + ['' % (imp.get_tag(), ma_triplet)]:
+ basename = module_name + so_suffix
+ if path is None:
+ path = sys.path
+ # import from non root package would try __pycache__ which is
+ # cleaned by pypy installation
+ path.insert(0, "/usr/lib/pypy/dist-packages/zmq/cffi_core")
+ for dirname in path:
+ filename = os.path.join(dirname, basename)
+ if os.path.isfile(filename):
+ return filename
+cffi.vengine_gen.VGenericEngine.find_module = vengine_gen_find_module
from zmq.cffi_core import (constants, error, message, context, socket,
_poll, devices, stopwatch)
......@@ -25,5 +25,9 @@ override_dh_install:
rm -rf debian/python3-zmq/usr/lib/python*/dist-packages/zmq/cffi_core/
rm -rf debian/python3-dbg-zmq/usr/lib/python*/dist-packages/zmq/cffi_core/
# cython core is only used for cpython
rm -rf debian/pypy-zmq/usr/lib/python*/dist-packages/zmq/core/
rm -rf debian/pypy-zmq/usr/lib/pypy/dist-packages/zmq/core/
# build shared libraries for pypy and install them
pypy -c 'import zmq'
mv -v zmq/cffi_core/__pycache__/*.c zmq/cffi_core/__pycache__/*so \
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment