aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cryptography/hazmat/bindings/utils.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/cryptography/hazmat/bindings/utils.py b/cryptography/hazmat/bindings/utils.py
index f79d0cb5..318b82bb 100644
--- a/cryptography/hazmat/bindings/utils.py
+++ b/cryptography/hazmat/bindings/utils.py
@@ -52,7 +52,8 @@ def build_ffi(module_prefix, modules, pre_include, post_include, libraries):
includes.append(module.INCLUDES)
customizations.append(module.CUSTOMIZATIONS)
- ffi.cdef("\n".join(types + functions + macros))
+ cdef_sources = types + functions + macros
+ ffi.cdef("\n".join(cdef_sources))
# We include functions here so that if we got any of their definitions
# wrong, the underlying C compiler will explode. In C you are allowed
@@ -71,7 +72,7 @@ def build_ffi(module_prefix, modules, pre_include, post_include, libraries):
)
lib = ffi.verify(
source=source,
- modulename=_create_modulename(ffi, source, sys.version),
+ modulename=_create_modulename(cdef_sources, source, sys.version),
libraries=libraries,
ext_package="cryptography",
)
@@ -87,7 +88,7 @@ def build_ffi(module_prefix, modules, pre_include, post_include, libraries):
return ffi, lib
-def _create_modulename(ffi, source, sys_version):
+def _create_modulename(cdef_sources, source, sys_version):
"""
cffi creates a modulename internally that incorporates the cffi version.
This will cause cryptography's wheels to break when the version of cffi
@@ -95,10 +96,10 @@ def _create_modulename(ffi, source, sys_version):
resolve this we build our own modulename that uses most of the same code
from cffi but elides the version key.
"""
- key = '\x00'.join([sys_version[:3], source] + ffi._cdefsources)
+ key = '\x00'.join([sys_version[:3], source] + cdef_sources)
key = key.encode('utf-8')
k1 = hex(binascii.crc32(key[0::2]) & 0xffffffff)
k1 = k1.lstrip('0x').rstrip('L')
k2 = hex(binascii.crc32(key[1::2]) & 0xffffffff)
k2 = k2.lstrip('0').rstrip('L')
- return '_cffi_{0}{1}'.format(k1, k2)
+ return '_Cryptography_cffi_{0}{1}'.format(k1, k2)