move native feature verification to setup.py
parent
7782fa8ddb
commit
3d96e3e3e0
23
setup.py
23
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 <wolfssl/options.h> 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(
|
||||
|
|
|
|||
|
|
@ -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 <wolfssl/options.h> 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(
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue