diff --git a/setup.py b/setup.py index 4c06143..ec55ff1 100755 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ sys.path.insert(0, package_dir) import wolfssl from wolfssl._build_wolfssl import build_wolfssl +from wolfssl._build_wolfssl import wolfssl_inc_path, wolfssl_lib_path # long_description @@ -43,6 +44,26 @@ with open("LICENSING.rst") as licensing_file: long_description = long_description.replace(".. include:: LICENSING.rst\n", licensing_file.read()) +def verify_wolfssl_config(): + # verify wolfSSL library has been configured correctly, so that cffi + # binding work correctly. + + # open header to parse for #define's + # This will throw a FileNotFoundError if not able to find options.h + optionsHeaderPath = wolfssl_inc_path() + "/wolfssl/options.h" + optionsHeader = open(optionsHeaderPath, 'r') + optionsHeaderStr = optionsHeader.read() + optionsHeader.close() + + # require HAVE_SNI (--enable-sni) in native lib + if '#define HAVE_SNI' not in optionsHeaderStr: + raise RuntimeError("wolfSSL needs to be compiled with --enable-sni") + + # require OPENSSL_EXTRA (--enable-opensslextra) in native lib + if '#define OPENSSL_EXTRA' not in optionsHeaderStr: + raise RuntimeError("wolfSSL needs to be compiled with " + "--enable-opensslextra") + class cffiBuilder(build_ext, object): def build_extension(self, ext): @@ -54,6 +75,8 @@ class cffiBuilder(build_ext, object): if os.environ.get("USE_LOCAL_WOLFSSL") is None: build_wolfssl(wolfssl.__wolfssl_version__) + verify_wolfssl_config() + super(cffiBuilder, self).build_extension(ext) setup( diff --git a/src/wolfssl/_build_ffi.py b/src/wolfssl/_build_ffi.py index bfcc629..1a15344 100644 --- a/src/wolfssl/_build_ffi.py +++ b/src/wolfssl/_build_ffi.py @@ -26,21 +26,6 @@ from distutils.util import get_platform from cffi import FFI from wolfssl._build_wolfssl import wolfssl_inc_path, wolfssl_lib_path -# open header to parse for #define's -# This will throw a FileNotFoundError if not able to find options.h -optionsHeaderPath = wolfssl_inc_path() + "/wolfssl/options.h" -optionsHeader = open(optionsHeaderPath, 'r') -optionsHeaderStr = optionsHeader.read() -optionsHeader.close() - -# require HAVE_SNI (--enable-sni) in native lib -if '#define HAVE_SNI' not in optionsHeaderStr: - raise SystemExit("wolfSSL needs to be compiled with --enable-sni") - -# require OPENSSL_EXTRA (--enable-opensslextra) in native lib -if '#define OPENSSL_EXTRA' not in optionsHeaderStr: - raise SystemExit("wolfSSL needs to be compiled with --enable-opensslextra") - ffi = FFI() ffi.set_source( diff --git a/src/wolfssl/_build_wolfssl.py b/src/wolfssl/_build_wolfssl.py index f398186..a5d9751 100644 --- a/src/wolfssl/_build_wolfssl.py +++ b/src/wolfssl/_build_wolfssl.py @@ -41,7 +41,7 @@ WOLFSSL_SRC_PATH = local_path("lib/wolfssl/src") def wolfssl_inc_path(): wolfssl_path = os.environ.get("USE_LOCAL_WOLFSSL") if wolfssl_path is None: - return local_path("lib/wolfssl") + return local_path("lib/wolfssl/src") else: if os.path.isdir(wolfssl_path) and os.path.exists(wolfssl_path): return wolfssl_path + "/include"