Skip to content
Snippets Groups Projects
Commit 5a586861 authored by Donald Stufft's avatar Donald Stufft
Browse files

Updates to properly handle CFFI

parent 449a6e27
No related branches found
No related tags found
No related merge requests found
...@@ -35,4 +35,4 @@ recursive-include tests *.py ...@@ -35,4 +35,4 @@ recursive-include tests *.py
recursive-include tests/data * recursive-include tests/data *
# Remove CFFI files # Remove CFFI files
recursive-exclude nacl _cffi_*.c recursive-exclude nacl *.c
...@@ -79,11 +79,6 @@ ffi.cdef( ...@@ -79,11 +79,6 @@ ffi.cdef(
ffi.verifier = Verifier(ffi, ffi.verifier = Verifier(ffi,
"#include <sodium.h>", "#include <sodium.h>",
# We need to set a tmp directory otherwise when build_ext is run it'll get
# built in nacl/*.so but when ffi.verifier.load_library() is run it'll
# look (and ultimately build again) in nacl/__pycache__/*.so
tmpdir=os.path.abspath(os.path.dirname(__file__)),
# We need to link to the sodium library # We need to link to the sodium library
libraries=["sodium"], libraries=["sodium"],
...@@ -141,6 +136,12 @@ class Library(object): ...@@ -141,6 +136,12 @@ class Library(object):
self._ffi = ffi self._ffi = ffi
self._initalized = False self._initalized = False
# This prevents the compile_module() from being called, the module
# should have been compiled by setup.py
def _compile_module(*args, **kwargs):
raise RuntimeError("Cannot compile module during runtime")
self._ffi.verifier.compile_module = _compile_module
def __getattr__(self, name): def __getattr__(self, name):
if not self._initalized: if not self._initalized:
self._lib = self._ffi.verifier.load_library() self._lib = self._ffi.verifier.load_library()
......
...@@ -185,7 +185,7 @@ setup( ...@@ -185,7 +185,7 @@ setup(
"include_dirs": [ "include_dirs": [
sodium("include/sodium"), sodium("include/sodium"),
], ],
"sources": map(sodium, [ "sources": [sodium(s) for s in [
"crypto_auth/crypto_auth.c", "crypto_auth/crypto_auth.c",
"crypto_auth/hmacsha256/auth_hmacsha256_api.c", "crypto_auth/hmacsha256/auth_hmacsha256_api.c",
"crypto_auth/hmacsha256/ref/hmac_hmacsha256.c", "crypto_auth/hmacsha256/ref/hmac_hmacsha256.c",
...@@ -312,7 +312,7 @@ setup( ...@@ -312,7 +312,7 @@ setup(
"sodium/core.c", "sodium/core.c",
"sodium/utils.c", "sodium/utils.c",
"sodium/version.c", "sodium/version.c",
]), ]],
}), }),
], ],
......
...@@ -4,5 +4,4 @@ envlist = py26,py27,pypy,py32,py33 ...@@ -4,5 +4,4 @@ envlist = py26,py27,pypy,py32,py33
[testenv] [testenv]
deps = deps =
pytest pytest
pytest-cov commands = py.test
commands = py.test --cov=nacl/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment