Package: pyzmq / 16.0.2-2

cffi-fix.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
From 85e287bd265ec61def5e687817861fa5df826d5e Mon Sep 17 00:00:00 2001
From: SVN-Git Migration <python-modules-team@lists.alioth.debian.org>
Date: Thu, 8 Oct 2015 13:36:52 -0700
Subject: 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.
Also use fixed path in a place passed to cffi to get the same checksum
in build and install. After it is installed no build is needed so it
doesn't matter if its wrong.

This patch assumes pypy 2.2 api, won't work with 2.1 as so_suffices is
no list.

Bug: https://bitbucket.org/cffi/cffi/issue/109/enable-sane-packaging-for-cffi
Patch-Name: cffi-fix.patch
---
 zmq/backend/cffi/__init__.py | 24 ++++++++++++++++++++++++
 zmq/backend/cffi/_cffi.py    |  4 ++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/zmq/backend/cffi/__init__.py b/zmq/backend/cffi/__init__.py
index ca3164d..f67b719 100644
--- a/zmq/backend/cffi/__init__.py
+++ b/zmq/backend/cffi/__init__.py
@@ -3,6 +3,30 @@
 # Copyright (C) PyZMQ Developers
 # Distributed under the terms of the Modified BSD License.
 
+import imp
+import os.path
+import sys
+
+import cffi.vengine_cpy
+import cffi.vengine_gen
+_ma_triplet = getattr(getattr(sys, 'implementation', sys), '_multiarch', None)
+
+def vengine_gen_find_module(self, module_name, path, so_suffixes):
+    for so_suffix in so_suffixes + ['.%s-%s.so' % (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.append("/usr/lib/pypy/dist-packages/zmq/backend/cffi")
+        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.backend.cffi import (constants, error, message, context, socket,
                            _poll, devices, utils)
 
diff --git a/zmq/backend/cffi/_cffi.py b/zmq/backend/cffi/_cffi.py
index 3fcf072..3580f8f 100644
--- a/zmq/backend/cffi/_cffi.py
+++ b/zmq/backend/cffi/_cffi.py
@@ -18,10 +18,10 @@ base_zmq_version = (3,2,2)
 def load_compiler_config():
     """load pyzmq compiler arguments"""
     import zmq
-    zmq_dir = dirname(zmq.__file__)
+    zmq_dir = "zmq"
     zmq_parent = dirname(zmq_dir)
     
-    fname = join(zmq_dir, 'utils', 'compiler.json')
+    fname = join(dirname(zmq.__file__), 'utils', 'compiler.json')
     if os.path.exists(fname):
         with open(fname) as f:
             cfg = json.load(f)