From 2a43b8cc0e94228d52eccf899edafe0f79083cb9 Mon Sep 17 00:00:00 2001 From: Wouter Bolsterlee <uws@xs4all.nl> Date: Tue, 12 Nov 2013 20:17:41 +0100 Subject: [PATCH] Call ffi.cdef() for header files in predictable order Always call ffi.cdef() with a consistent ordering of the header files. This avoids problems where CFFI generates different checksums (used in .so filenames) at compile time and runtime, and tries to load the wrong .so file. Fixes issue #53 (https://github.com/pyca/pynacl/issues/53) --- src/nacl/_lib/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nacl/_lib/__init__.py b/src/nacl/_lib/__init__.py index 582fd261..d8f787ec 100644 --- a/src/nacl/_lib/__init__.py +++ b/src/nacl/_lib/__init__.py @@ -36,8 +36,10 @@ HEADERS = glob.glob( ffi = FFI() -# Add all of our header files -for header in HEADERS: +# Add all of our header files, but sort first for consistency of the +# hash that CFFI generates and uses in the .so filename (the order of +# glob() results cannot be relied on) +for header in sorted(HEADERS): with open(header, "r") as hfile: ffi.cdef(hfile.read()) -- GitLab