Skip to content

Commit 3d96e3e

Browse files
committed
move native feature verification to setup.py
1 parent 7782fa8 commit 3d96e3e

3 files changed

Lines changed: 24 additions & 16 deletions

File tree

setup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import wolfssl
3535
from wolfssl._build_wolfssl import build_wolfssl
36+
from wolfssl._build_wolfssl import wolfssl_inc_path, wolfssl_lib_path
3637

3738

3839
# long_description
@@ -43,6 +44,26 @@
4344
long_description = long_description.replace(".. include:: LICENSING.rst\n",
4445
licensing_file.read())
4546

47+
def verify_wolfssl_config():
48+
# verify wolfSSL library has been configured correctly, so that cffi
49+
# binding work correctly.
50+
51+
# open <wolfssl/options.h> header to parse for #define's
52+
# This will throw a FileNotFoundError if not able to find options.h
53+
optionsHeaderPath = wolfssl_inc_path() + "/wolfssl/options.h"
54+
optionsHeader = open(optionsHeaderPath, 'r')
55+
optionsHeaderStr = optionsHeader.read()
56+
optionsHeader.close()
57+
58+
# require HAVE_SNI (--enable-sni) in native lib
59+
if '#define HAVE_SNI' not in optionsHeaderStr:
60+
raise RuntimeError("wolfSSL needs to be compiled with --enable-sni")
61+
62+
# require OPENSSL_EXTRA (--enable-opensslextra) in native lib
63+
if '#define OPENSSL_EXTRA' not in optionsHeaderStr:
64+
raise RuntimeError("wolfSSL needs to be compiled with "
65+
"--enable-opensslextra")
66+
4667
class cffiBuilder(build_ext, object):
4768

4869
def build_extension(self, ext):
@@ -54,6 +75,8 @@ def build_extension(self, ext):
5475
if os.environ.get("USE_LOCAL_WOLFSSL") is None:
5576
build_wolfssl(wolfssl.__wolfssl_version__)
5677

78+
verify_wolfssl_config()
79+
5780
super(cffiBuilder, self).build_extension(ext)
5881

5982
setup(

src/wolfssl/_build_ffi.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@
2626
from cffi import FFI
2727
from wolfssl._build_wolfssl import wolfssl_inc_path, wolfssl_lib_path
2828

29-
# open <wolfssl/options.h> header to parse for #define's
30-
# This will throw a FileNotFoundError if not able to find options.h
31-
optionsHeaderPath = wolfssl_inc_path() + "/wolfssl/options.h"
32-
optionsHeader = open(optionsHeaderPath, 'r')
33-
optionsHeaderStr = optionsHeader.read()
34-
optionsHeader.close()
35-
36-
# require HAVE_SNI (--enable-sni) in native lib
37-
if '#define HAVE_SNI' not in optionsHeaderStr:
38-
raise SystemExit("wolfSSL needs to be compiled with --enable-sni")
39-
40-
# require OPENSSL_EXTRA (--enable-opensslextra) in native lib
41-
if '#define OPENSSL_EXTRA' not in optionsHeaderStr:
42-
raise SystemExit("wolfSSL needs to be compiled with --enable-opensslextra")
43-
4429
ffi = FFI()
4530

4631
ffi.set_source(

src/wolfssl/_build_wolfssl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def local_path(path):
4141
def wolfssl_inc_path():
4242
wolfssl_path = os.environ.get("USE_LOCAL_WOLFSSL")
4343
if wolfssl_path is None:
44-
return local_path("lib/wolfssl")
44+
return local_path("lib/wolfssl/src")
4545
else:
4646
if os.path.isdir(wolfssl_path) and os.path.exists(wolfssl_path):
4747
return wolfssl_path + "/include"

0 commit comments

Comments
 (0)